Skip to Main Content
PHPUnit Pocket Guide
book

PHPUnit Pocket Guide

by Sebastian Bergmann
September 2005
Intermediate to advanced content levelIntermediate to advanced
90 pages
1h 53m
English
O'Reilly Media, Inc.
Content preview from PHPUnit Pocket Guide

Chapter 5. The Command-Line Test Runner

The PHPUnit command-line test runner is invoked through the phpunit command. The following code shows how to run tests with the PHPUnit command-line test runner:

phpunit ArrayTest
PHPUnit 2.3.0 by Sebastian Bergmann.

..

Time: 0.067288

OK (2 tests)

For each test run, the PHPUnit command-line tool prints one character to indicate progress:

. Printed when the test succeeds.
F Printed when an assertion fails while running the test method.
E Printed when an error occurs while running the test method.
I Printed when the test is marked as being incomplete or not yet implemented (see "Incomplete Tests," later in this book).

PHPUnit distinguishes between failures and errors. A failure is a violated PHPUnit assertion. An error is an unexpected exception or a PHP error. Sometimes this distinction proves useful because errors tend to be easier to fix than failures. If you have a big list of problems, it's best to tackle the errors first and see if you have any failures left when the errors are all fixed.

Let's take a look at the command-line test runner's switches in the following code:

phpunit --help PHPUnit 2.3.0 by Sebastian Bergmann. Usage: phpunit [switches] UnitTest [UnitTest.php] --coverage-data <file> Write code-coverage data in raw format to file. --coverage-html <file> Write code-coverage data in HTML format to file. --coverage-text <file> Write code-coverage data in text format to file. --testdox-html <file> Write agile documentation in HTML format ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering PHP 7

Mastering PHP 7

Branko Ajzele

Publisher Resources

ISBN: 0596101031Errata Page