Unit Testing with phpUnit (models+controllers+fixtures) - want it? |
[eluser]rafsoaken[/eluser]
Hi all, Despite CI's obvious greatness some may find it lacks easy Unit Testing (no sight of them in 1.6, besides that puny Test class). I am currently cooking up a small wrapper lib to use phpUnit 3.2, yaml (db)fixtures with Spyc, and yet to come some sort of test scaffolding. At the current stage a test case looks like this: Code: include_once dirname(__FILE__).'/../CIUnit.php'; So, anyone interested in this? I really would like to know as the code is good enough for internal use but would need some lovin' to make it available to others... Besides, are there any syntax requests you find useful?, or other needs that should be catered (like eg. it should play nice with your simpletest testcases, css selectors, etc.) Cheers rafsoaken
[eluser]John Fuller[/eluser]
Sure, why not polish it up and release it? There is also a SimpleTest library which Ciscoheat released which works pretty well. I don't know how SimpleTest compares with phpUnit though.
[eluser]Unknown[/eluser]
rafsoaken, I just found your post because I'm interested enough in this sort of ability to start working on it myself. I really like that you're adding classic functional tests (testing the controllers and output); I'm currently most interested in the unit testing aspect and am trying to figure out how to wrap the models for testing... My thought was to create a custom include so I can still use the phpunit command from the command line; what's your approach? Adam
[eluser]rafsoaken[/eluser]
Here we are, the first release CIUnit, unit testing with phpUnit for Codeigniter. We are at v0.10, hooray! Download it here: fooStack v0.10 for Codeigniter It's called "fooStack", consisting of a drop-in replacment of the Codeigniter.php file (actually it only defines the CIUnit version constant and per default extends the codeigniter Loader and Output class - use 'extends fooLoader' and 'fooOutput' to extend them), and all the classes needed (eg for parsing yaml and generating fixtures) Tests of CIUnit itself are of course included and should assure you that your setup of fooStack works just fine. I included a short description on how to set it up in the fooStack.html file, please drop me a line or post here if you start using it. cheers rafsoaken
[eluser]Jamongkad[/eluser]
Oh awesome up until recently I thought I was the only one who thought CI's unit testing suite was lacking. You just spared me the effort of porting SimpleTest to CI. Thanks!
[eluser]dsloan[/eluser]
Certainly looks like a great project. However, I'm having a problem getting up and running with testing my application. See my post on the problem at http://ellislab.com/forums/viewthread/87635/
[eluser]rafsoaken[/eluser]
The new version v0.12 of CIUnit is available, hooray! Some minor small bugs have been fixed, and CIUnit now is very stable for CodeIgniter versions 1.62, 1.63 and the upcoming 1.70 release (tested against trunk). Get this beauty here: fooStack/CIUnit v0.12 for Codeigniter Additionally the project is now also available from a public mercurial repository: fooStack/CIUnit bitbucket repository Happy testing! Clemens
[eluser]rafsoaken[/eluser]
The repository (mercurial) is now to be found at: http://www.bitbucket.org/rafsoaken/ciunit/overview/ Check it out ! |
Welcome Guest, Not a member yet? Register Sign In |