Running a PHPUnit Test Case
This procedure describes how to run a PHPUnit Test Case and how to analyze
Before running a PHPUnit Test Case, one needs to be created by following
the instructions under 'Creating
a PHPUnit Test Case'.
To Run a PHPUnit Test Case:
Open your PHPUnit Test Case
file in the editor.
To run the PHPUnit Test
Case, click the arrow next to the Run
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
-Or- to debug the PPHUnit Test Case, click the arrow next to the debug
button on the toolbar and select Debug As | PHP Unit Test -or-
from the Main Menu, go to Run and select Debug As | PHP Unit Test
-or- right-click the file in PHP Explorer view and select Debug As | PHP
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.
In the main area of the
PHPUnit test view, the results for each of the
tests run will be displayed.
Tests that have passed successfully will be displayed with a green
Tests that have failed will be displayed with a blue X icon.
Functions with tests that have not been implemented (i.e. functions
that tests have not been created for), will have passed but will have
a note indicating that they have not been implemented.
The number at the top of
the view indicates how many tests have been run. Tests may not be run
if an 'exit' command is given or if a fatal error is encountered.
Click the 'Show failures
only' icon to only view failed results.
Select a failed result to
view it in the Failure Trace view. Click the Filter Stack Trace icon
to display only functions relevant to your application and not PHPUnit
Double-click on a failed
result 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:
percentage in the Covered Lines column displays
the percentage of lines executed out of the total number of executable
number of 'visited' lines are the number of executable code lines.
number of 'significant' lines are the number of significant (i.e. executable)
number of 'total' lines is the total number of lines in the file.
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.
'Visited' lines will be highlighted in blue.
'Significant' lines will be highlighted in pink.
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
You can create reports based on your results using the Report Generator
icon . See Reporting on
PHPUnit Test Results for more details.