![]() |
unit test / SimpleTest - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: unit test / SimpleTest (/showthread.php?tid=3864) |
unit test / SimpleTest - El Forum - 10-25-2007 [eluser][email protected][/eluser] Hey guys, I have tried migrating SimpleTest with CI, and am having issues of where test files should go. I am trying to Unit Test a CI application, and am not sure how to set the paths so everything is picked up. I am having issues of where files should reside, and how paths should be set?? Any guidance will help. Thank you. unit test / SimpleTest - El Forum - 11-30-2007 [eluser]Don Pinkster[/eluser] Discovered this thread while searching how to unittest with CodeIgniter. Because I really dislike the CI's included UnitTest I implemented SimpleTest in my application. Currently Im only testing my models yet, but going to write tests for my whole application when I have the time. I have one file, which is small but oh so important: Code: <?PHP This is my "test" controller which executes the tests: Code: <?php And inside my test cases I have things like this: Code: <?PHP unit test / SimpleTest - El Forum - 11-30-2007 [eluser][email protected][/eluser] Hey Don, This looks great, and is exactly what I was referring to, nice job with the code I understand 99% of what is going on. There a few things I'm not understanding though. 1) In TestHelper.php, how doest $this->CI =& get_instance() get a reference to the actual CI instance. 2) In the Test controller, what is intranet.php and how can I get it? 3) What urls do you hit to test this? ( I am assuming 'http://localhost/test/Test' will hit all the tests. Please respond whenever you get a chance. Thank you for your help thus far. unit test / SimpleTest - El Forum - 12-01-2007 [eluser]Don Pinkster[/eluser] Hi, 1. get_instance(); is a method provided by CI itself. Its in the Base5.php or something like that in the system folder. 2. Intranet is just a abstract controler I innerhit every controller form. Code: <?php I just hit http://intranet/test for all tests or http://intranet/test/contacts_model to execute the contacts_model tests. Yesterday I modified my own code a bit. I have now a .yml file with my fixtures in it which will be loaded in the database prefore testing and get deleted after testing. unit test / SimpleTest - El Forum - 12-03-2007 [eluser][email protected][/eluser] Don, This is great. Thank you very much for your help. unit test / SimpleTest - El Forum - 12-11-2007 [eluser][email protected][/eluser] Hey Don, I started using Simpletests's WebTestCase to test the controllers in the system. Everything was working fine until I got to a section on our site where the user must be logged in. I can't seem to figure out a way how to log the user in, and continue testing with it. In other words, every request I hit with WebTestCase is looked as a separate request and there is not state saved. I was just wondering if you have any advice? Thank you. Kamil |