Smutty

MVC Framework

SmuttyTests

Smutty provides an easy way of writing tests for your application (internally it uses the SimpleTest framework). If you look in your application folder you will see a folder called tests, this is where you should put all your test files. But what are these test files?

Test Cases

Test cases are just standard classes which extend the Smutty_Test class. Then you write tests as functions inside these classes. For example, if you have a file called application/tests/PostTest.php that looked like this...

class PostTest extends Smutty_Test {

    function testSomething() {
        // test code here...
    }

}

All methods in this class which use the test prefix will be used as tests. You can then run this test using smut by executing the following command.

./smut test PostTest

Test Suites

You can also group many test cases together into test suites. To do this just create a file in your tests folder like the one that follows (example name MySuite.php).

<?

$suite = new Smutty_Test_Suite();
$suite->addTest( 'MyTest' );
$suite->addTest( 'AnotherTestClass' );
$suite->run();

?>

This can then be run the same as individual test cases with the following smut command.

./smut test MySuite

Links: Post a comment

Useful Pages

Links