I do some PHP with Kohana 3 (IDE:Netbeans), and got excited about idea of writing tests for code. It sounds pretty cool thing to do, but i have few complications and worries.
-
Why using Kohana unittest module in browser is like 5 times faster then running tests in Netbeans or command Line ?
-
How could i exclude all kohana internal tests? In the PHPUnit .xml configuration file ?
-
Why when run any test i’ve got in Netbeans panel two entries for it – one with yellow triangle (it says ‘file x skipped’), and entry with normal test result. I do get that double entries for every test, also those native from Kohana. I don’t mind but it’s strange.
-
All over the Web i see examples, tutorials and screencasts of PHPUnit with sample classes and methods that add two numbers or displays name or do some other trivial things. I’ve learnt to do those kind of assertions, but how could i test my code in Kohana? My Models are 90% ORM stuff. Controllers? How? Any ‘How-tos’ and examples are welcome.
I’ve seen in Ruby tutorial about Rspec a way to test DB by using testing enviroment Databse and rollbacks after finisning tests. Also user actions like clicking links were simulated. Is it possible with PHPUnit ?
There always has been a lot of discussion on what has to be tested and what has not to be tested. Generally my opinion is that you shouldn’t test things that should work, like the database driver and connection, this has little to do with your code. Some then argue that you should be able to test it anyway, but in most environment this isn’t an easy thing to do and usually a big hassle.
Generally controller actions should be tested as well as any helpers or modules you’ve written. Usually one uses the paradigm of a mocking framework to get around the database. The good thing about this is a gigantic speed increase in your testing. There are several PHP mocking frameworks as well I suppose.
Another great thing to keep in mind is that you also have user testing. This cannot be simulated with the kind of tests you write in kohana. For this it is interesting to look at http://seleniumhq.org/