User Guide > Concepts > PHPUnit Testing

PHPUnit Testing

Unit testing is a procedure to test your code to ensure that individual units of source code are working properly and that the right output is being generated. Tests can be run on all or some functions within files, meaning that tests can be conducted before the file has been fully developed. Each test case should be independent of others to ensure that test results can pinpoint the location of the error.

 

Running unit tests can ensure that your code is stable and functioning correctly, and can help you to diagnose errors.

PHPUnit Test Cases

PHPUnit Test Cases can be created for each class within a file. Running a PHPUnit Test allows you to see which functions within the test are working correctly.

See Creating a PHPUnit Test Case and Running a PHPUnit Test Case for more information.

PHPUnit Test Suites

PHPUnit Test Suites can be created to run several PHPUnit test cases at once. See Creating a PHPUnit Test Suite and Running a PHPUnit Test Suite for more information.

Running PHPUnit Test Cases/Suites

Running a PHP Unit Test Case/Suite will result in the PHPUnit view being displayed, showing the results of the tests that were run.

Debugging PHPUnit Test Cases/Suites

Debugging a PHPUnit Test Case/Suite will result in the PHPUnit view being displayed, showing the results of the tests that were run, in addition to the normal debug functionality. This will also allow you to debug and analyze PHPUnit libraries.

Profiling PHPUnit Test Cases/Suites

Profiling a PHPUnit Test Case/Suite will result in the PHPUnit view being displayed, showing the results of the tests that were run, in addition to the normal profiling functionality. This will also allow you to profile and analyze PHPUnit libraries.

PHPUnit Reporting

Once a PHPUnit Test has been run, Zend Studio can generate a range of reports to easily view and analyze your tests.

The types of reports available are:

Custom XSL reports can also be generated by selecting the 'Generate with XSL...' option and selecting a previously created XSL report. These will then be added to the list of available reports.

See Reporting on PHPUnit Test Results for more information.

 

 

Related Links:

Using PHPUnit Testing

Working with PHPUnit Testing

Creating a PHPUnit Test Case

Creating a PHPUnit Test Suite

Running a PHPUnit Test Case

Running a PHPUnit Test Suite

PHPUnit Preferences

 

 

©1999-2013 Zend Technologies LTD. All rights reserved.