If you followed Chapter 1, Installing PHPUnit, you should have PHPUnit installed. You can test this by running the following command line:
phpunit --version
You should see an output similar to the following result:
PHPUnit 3.7.30 by Sebastian Bergmann.
If you see a command not found, or a similar error, please see Chapter 1, Installing PHPUnit, on how to install PHPUnit; this error means that PHPUnit has not been installed correctly.
With PHPUnit, you can specify what exactly you want to run, a test case or all the tests, or what to include or exclude.
To run all tests in a test case (the test
class), just provide the filename as the first parameter, as shown in the following command line:
phpunit UserTest.php
To run all tests from a directory, just provide the directory name as the first parameter, as shown in the following command line:
phpunit ./Tests