Test Driven Development
By Marcus Baker2004-01-25
A Simple Test Case
If this is the case, we can write a do nothing test case (test/config_test.php) as follows...
<?php
define('SIMPLE_TEST', 'simpletest/');
require_once(SIMPLE_TEST . 'unit_tester.php');
require_once(SIMPLE_TEST . 'reporter.php');
class ConfigurationTest extends UnitTestCase {
function ConfigurationTest() {
$this->UnitTestCase();
}
}
$test = &new ConfigurationTest();
$test->run(new HtmlReporter());
?>
The first block includes the files needed by the tester with the proviso that the SIMPLE_TEST constant must point at the SimpleTest directory. The second block is the actual test case, more on this in a minute. The third block creates the test case and runs it.
To keep things simple I have compressed the entire test suite into a single, rather cluttered, file. In the real world you would only need the actual test case, as the running and grouping of tests would be in a separate runner script.
If you point your web browser at the test script it will actually run successfully...
configurationtest
1/1 test cases complete:0 passes, 0 fails and 0 exceptions.
Tutorial pages:
|
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Test Driven Development"
You must be logged in to post a comment.
Link to This Tutorial Page!

