unit test / SimpleTest |
[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.
[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
[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.
[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.
[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 |
Welcome Guest, Not a member yet? Register Sign In |