SimpleTest showing description of error
The assert* methods of SimpleTest allow an optional additional parameter which is the description of the current assertion. In case of failure it will be shown instead of the details of the error
examples/php/simpletest/st04.php
<?php require_once(dirname(__FILE__) . '/../../../tools/simpletest/autorun.php'); require_once(dirname(__FILE__) . '/../includes/mylib.php'); class TestOfAdd extends UnitTestCase { function testAdd() { $this->assertEqual(add(1,1), 2, "1+1"); $this->assertEqual(add(2,2), 4, "2+2"); $this->assertEqual(add(1,1,1), 3, "three params 1+1+1"); } } ?>
Output:
examples/php/simpletest/st04.txt
st04.php Fail: TestOfAdd -> testAdd -> three params 1+1+1 at [.../examples/php/simpletest/st04.php line 11] 1/1 test cases complete: 2 passes, 1 fails and 0 exceptions.
With the last row being RED