PHPUnit2_Framework_TestResult
While you are running all these tests, you need somewhere to store the results: how many tests ran, which failed, and how long they took.
PHPUnit2_Framework_TestResult
collects results. A single PHPUnit2_Framework_TestResult
is passed around the whole tree of tests; when a test runs or fails, the fact is noted in the PHPUnit2_Framework_TestResult
. At the end of the run, PHPUnit2_Framework_TestResult
contains a summary of all the tests.
This example shows the PHPUnit test suite running:
php AllTests.php
PHPUnit 2.3.0 by Sebastian Bergmann.
.........................................
.........................................
.......
Time: 4.642600
OK (89 tests)
PHPUnit2_Framework_TestResult
is also a subject that can be observed by other objects wanting to report test progress. For example, a graphical test runner might observe the PHPUnit2_Framework_TestResult
and update a progress bar every time a test starts.
Table 13 summarizes the external protocols of PHPUnit2_ Framework_TestResult
.
Table 13. TestResult external protocols
Method |
Description |
---|---|
|
Records that running $test caused $e to be thrown unexpectedly. |
|
Records that running $test caused $e to be thrown unexpectedly. |
|
Returns the errors recorded. |
|
Get PHPUnit Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.