Welcome Guest, Not a member yet? Register   Sign In
Some help for Unit Testing, part II
#7

[eluser]JensRoland[/eluser]
Great post! T'mo and redguy, you guys just ROCK!!!

All right - I've finished my unit testing suite, based on the code from this post (although I've added a lot to it now). I've decided to call it Toast, since Test seemed too generic, and Test_Suite_Built_On_T'mo's_Code_With_Redguy's_Functions_And_Expanded_By_Me just seemed a bit... wordy. What I'm trying to say is, I didn't name it and put it on my website to steal any thunder from you two - you are awesome, and all credit for the base of this goes to you - but it just needed a name, and 'Toast' seemed nice and friendly.

So anyway, here goes:

Toast - Unit testing for CodeIgniter

* lightweight and unobtrusive - the entire suite has just 2 code files, and one of them is optional ;-)

* works with CI with no changes - just drop it in and it works

* simple JUnit-style syntax

* works entirely in the browser - no need for shell access

* run single tests, sets of tests, or all tests at once (all in the browser)

* auto-benchmarking using CI's benchmarking class

Here's an example test class - hopefully enough to get you interested:

Code:
require_once(APPPATH . '/controllers/test/Toast.php');

class My_test_class extends Toast
{

    function My_test_class()
    {
        parent::Toast(__FILE__); // Remember this
    }

    function test_some_action()
    {
        // Test code goes here
        $my_var = 2 + 2;
        $this->_assert_equals($my_var, 4);
    }

    function test_some_other_action()
    {
        // Test code goes here
        $my_var = true;
        $this->_assert_false($my_var);
    }

}

Anyway, I've put the source code up for download from my site, along with a simple user guide.

Toast v1.1 - Unit Testing suite for CodeIgniter

I'm hoping it can make it easier for people to do proper Test-Driven Development in CodeIgniter, since CodeIgniter rocks big time, and TDD is a rockin' way to code.

All the best-

/Jens Roland


Messages In This Thread
Some help for Unit Testing, part II - by El Forum - 04-14-2008, 12:23 AM
Some help for Unit Testing, part II - by El Forum - 04-14-2008, 06:53 AM
Some help for Unit Testing, part II - by El Forum - 04-14-2008, 10:28 AM
Some help for Unit Testing, part II - by El Forum - 04-15-2008, 12:08 AM
Some help for Unit Testing, part II - by El Forum - 04-15-2008, 08:10 PM
Some help for Unit Testing, part II - by El Forum - 04-20-2008, 12:33 PM
Some help for Unit Testing, part II - by El Forum - 01-17-2009, 10:42 PM
Some help for Unit Testing, part II - by El Forum - 01-17-2009, 10:49 PM
Some help for Unit Testing, part II - by El Forum - 01-18-2009, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB