Running a PHPUnit Test Suite
This procedure describes how to run a PHPUnit Test Suite and how to
analyze the results.
Before running a PHPUnit Test Suite, one needs to be created by following
the instructions under Creating
a PHPUnit Test Suite.
|
|
|
To run a PHPUnit Test Suite:
-
Open your PHPUnit
Test Suite.
-
Click the arrow
next to the Run button
on the toolbar and select Run
As | PHP Unit Test -or-
from the Main Menu, go to Run and select Run
As | PHP Unit Test
-or- right-click the file in PHP Explorer view and select
Run As | PHP Unit Test. All the PHPUnit Test Cases contained inside the PHPUnit Test
Suite will be run.
-
The PHPUnit view
will be displayed, with a section showing all the tests run
and the results, and two extra tabbed views showing code coverage
and failure trace. The results of the individual PHPUnit Test Cases will be displayed
in a tree diagram.
-
Expand the nodes
to see the results for each of the individual test cases. Tests that have passed successfully will be displayed with
a green tick icon. Tests that have failed will be displayed with a blue X icon.
Tests that are incomplete or skipped will be displayed with a warning icon.
-
Double-click on
a failed result (if applicable) to be taken to the test function
in the test file. To correct the failed result, either fix the test function
or the original function on which it was run.
-
The Code Coverage
display indicates how much of the code in both the original
file and the test file was run. Click on the code coverage statistics next to each file to
open the Code Coverage view displaying the code with the lines
of code that were run highlighted in blue.
-
Once you have
corrected errors, you can re-run the PHPUnit Test by clicking
the Run Last Test button
in the PHPUnit view until all tests pass successfully.
|
|