Table of Contents
PHPSpec offers two distinct modes for executing specs or examples. The
method most used throughout this manual requires using the command line
phpspec operation from a console like bash or MS-DOS.
An alternative method is available for executing specs by opening a .php URL
in your preferred web browser. This alternative can output in either plain
text or HTML as determined by various options.
Using PHPSpec from the console is the default option which requires no additional work from your perspective. Simple write your specs, navigate to their location on the command line, and issue a command like:
phpspec --recursive
This simple command recursively scans the current directory, and all child directories, for spec files and executes all the examples each spec file contains. The simplicity of this method makes using the console the most obvious choice. If you're using a Unix console then you even get some coloured output!
The phpspec console command has a number of
useful options which will be expanded substantially as development of
subsequent versions progresses. Each option usually has both a full length
version, and a shorter single character version. A table of the currently
available options is presented below.
Table 6.1. PHPSpec Console Options
| Fulltext Variant | Single Character Variant | Explanation |
|---|---|---|
| --recursive | -r | Recursively search the current directory and all child directories for specs, and execute all spec files and their examples as found. |
| --reporter=[html/console/text] | None | Use one of the available reporters to format output as either HTML, Text, or standard Console output. The default depends on the scenario but always defaults to Console when PHPSpec is run from the command line. |
| --specdoc | -s | Add specdoc output (i.e. a plain text list of all specifications) to the results output for all reporters. |