Welcome Guest, Not a member yet? Register   Sign In
Example of unit testing using CIUnit and PHPUnit
#1

[eluser]sidhartha[/eluser]
can any one post an example describing unit test in codeigniter using PHPUnit?

it will help a lot to me as well as to all.

please include a zipped folder with all files in mvc.

thanks to the noble heart.
#2

[eluser]Eric Barnes[/eluser]
Here you go:
http://www.knollet.com/foostack/

Or if you want simpletest:
http://github.com/ericbarnes/codeigniter-simpletest
#3

[eluser]sidhartha[/eluser]
hi Eric thaks for your reply.actually i am trying to use PHPUnit for CodeIgniter with the help of foostack.
when i run a test for a controller it shows me that "class controller not found". this is a problem in setting. if you can help me, it would be nice.
#4

[eluser]sidhartha[/eluser]
[quote author="sidhartha" date="1279802941"]hi Eric thaks for your reply.actually i am trying to use PHPUnit for CodeIgniter with the help of foostack.
when i run a test for a controller it shows me that "class controller not found". this is a problem in setting. if you can help me, it would be nice.[/quote]


This problem was due to a wrong folder setting. Actually I auto generated the skeleton for a test class using netbean IDE. The generated test file CountryTest.php resided in system/application/tests/system/application/controllers as per PHPUnit.

However for CIUnit point of view it should have been placed in system/application/tests/controllers as country.php is a controller.

similarly for all the test files for models must be placed in system/application/tests/models folder and test files for libraries must be placed in system/application/tests/libs folder and so on in CIUnit.


To have it working, copy/cut the auto generated skeleton file for test and paste it in required folder.




Theme © iAndrew 2016 - Forum software by © MyBB