assertEqual can actually get a third parameter too. This can hold a short description of what is being tested.


require_once(dirname(__FILE__) . '/../includes/mylib.php');

require_once 'PHPUnit/Framework.php';

class AddTest extends PHPUnit_Framework_TestCase {

    public function testAddTwo() {
        $this->assertEquals(2, add(1, 1), '1+1=2');
    public function testAddThree() {
        $this->assertEquals(3, add(1, 1, 1), '1+1+1=3');



In case of success this does not make a difference but when the test fails PHPUnit will display this message along with the name of the test function and the name of the test class. If the message is worded carefully it can further help in understanding the failure without even looking at the source code.

PHPUnit 3.3.17 by Sebastian Bergmann.


Time: 0 seconds

There was 1 failure:

1) testAddThree(AddTest)
Failed asserting that <integer:2> matches expected value <integer:3>.

Tests: 2, Assertions: 2, Failures: 1.