SimpleTester 1.0 - CI-library for unit testing |
[eluser]ciscoheat[/eluser]
Merry Christmas! Here's a little gift for those who likes Unit Testing, especially the Simpletest framework. It's a very easy-to-use testing library for CI that wraps the Simpletest framework. The default installation should work immediately for most of you. Installation instructions: 1. Download SimpleTester 1.0 here: http://codeigniter.com/wiki/SimpleTester...g_library/ 2. Unzip file to the application folder. 3. Download the SimpleTest framework here: http://simpletest.org/en/download.html 4. Gunzip that file to application/libraries (a folder called "simpletest" should be created in application/libraries) 5. Add "simpletester" to autoloading libraries in config/autoload.php 6. Done! Run your application. If nothing happens, it works. ![]() 7. Now you can check out the template test files in application/tests, and the SimpleTester configuration file in config. Try to change a test in a template test file to see if the installation really works. By failing a test, a big red bar should appear on the top of the page. All test files goes into "application/tests", use the template files for a quicker start. Good luck! If you develop on a machine where PHP doesn't see the server IP as 127.0.0.1, you must change the configuration file to allow the IP your development machine has. That is about the only issue I can see right now. Comments, improvements, anything is welcome. And remember, test before you code!
[eluser]ciscoheat[/eluser]
By the way, I'm a bit curious how widespread the Unit Testing concept is. I feel very unsecure without a unit test harness protecting the rules I've set up for how my code is working. What about you guys? /Andreas
[eluser]sikkle[/eluser]
i'll be more then please to see a tutorial about this implementation and also a basic use. let's say a damn old HOW-TO ![]() thanks.
[eluser]ciscoheat[/eluser]
No need for a howto, this isn't sendmail. ![]() If you're not into unit testing, there are many tutorials out there. The one from simpletest is pretty good: http://www.lastcraft.com/first_test_tutorial.php /Andreas
[eluser]esra[/eluser]
I believe that Jason Sweat, one of the SimpleTest maintainers, also wrote a book on PHP design patterns which incorporates SimpleTest's approach to testing in the examples: PHP|Architect's Guide to Design Patterns, ISBN 0-9735898-2-5
[eluser]ciscoheat[/eluser]
Just a notification that I've added this library to the wiki, with updated instructions. Download it here: http://codeigniter.com/wiki/SimpleTester...g_library/
[eluser]John Fuller[/eluser]
By the way, thanks for the work you did on this. I am using it for the app I am currently working on.
[eluser]ciscoheat[/eluser]
No problem, I'm glad it's used by someone. ![]()
[eluser]John Fuller[/eluser]
Yeah, it is working fine. I have just started getting into unit testing though, so I am not so advanced with it that I am running into missing features. ![]() At one point I was building my app and totally got myself lost. I was probably looking at the screen way too long and was way too tired. I couldn't get a certain section to work. So I busted out the CI unit tester and fixed a ton of problems and it worked! I then sprung for the SimpleTester and have been setting up tests ever since. I guess that is what unit testing is for. ![]()
[eluser]ciscoheat[/eluser]
I know just what you mean! When you start defining how the app should work, and the tests are enforcing that afterwards... it's a great feeling. Maybe you haven't gotten into Mock objects yet, but I think they are the best part of testing. I had a hard time to understand them in the beginning (I'll gladly explain if you like), but nowadays I mock everything to really narrow down the testing to only one class at a time. SimpleTest even has a "Partial mock" feature that enables you to replace only certain methods in a class. It's very useful, but doing that often might be a signal of a design problem. |
Welcome Guest, Not a member yet? Register Sign In |