highly extensible, highly enjoyable, BDD testing framework for PHP.
Natural
Testing with Peridot is natural. Write tests using the familiar describe-it
syntax. Easily and clearly describe how your code should behave in a language that makes sense. See getting started.
Fast
Peridot is lightweight. Peridot suites load and run faster than similar PHPUnit or phpspec suites. Have slow or bulky integration tests? No problem, Peridot can run your tests concurrently.
Installing Peridot
Peridot can be installed several ways:
Composer
Manual install
Manual install (local)
Getting Started
Peridot uses the familiar describe-it
syntax to create a clear and readable testing language.
peridot
-f, --focus
Only run tests whose title matches the provided pattern. See Focusing and Skipping.
-s, --skip
Only run tests whose title does not match the provided pattern. See Focusing and Skipping.
-g, --grep
Only run test files whose filename matches the provided pattern. The default grep pattern is *.spec.php
-b, --bail
Tell peridot to stop running tests as soon as there is a failure.
-r, --reporter
Select which reporter(s) to use (multiple values can be specified). See Specifying Reporters.
--reporters
List available test reporters.
-C, --no-colors
Disable colors in output.
-c, --configuration
A path to a peridot configuration file. Defaults to getcwd() . '/peridot.php'
Focusing and Skipping
See also Focused Specs, which allow you to focus tests without using command line options.
The --focus
and --skip
options can be used independently, or combined for complex test isolation.
If both are used, --skip
will take precedence.
The patterns accepted by both of these options are PCRE regular expressions that are evaluated against the "title" of the test.
The test title includes the description of the suite it is contained within, including any ancestors of that suite.
For example, the test shown in Getting Started has a title of: ArrayObject ->count() should return the number of items
.
If the provided pattern is not a complete PCRE regular expression, it will be surrounded in delimiters.
For example, --focus 'foo.*'
is equivalent to --focus '~\bfoo.*\b~'
.
If the provided pattern is not a valid PCRE regular expression, it will be treated as plain text.
For example, --focus 'foo('
is equivalent to --focus '~\bfoo\(\b~'
.
The addition of \b
simply prevents accidental matching of substrings.
Specifying Reporters
The --reporter
option can be used one or more times, and specifies the name of a reporter to use.
Reporter names are registered via ReporterFactory::register.
When multiple reporters are specified, the first reporter specified is the "primary" reporter, and any output generated by this reporter will be displayed as the suite runs. Any subsequent reporters will have their output buffered, and this output will be displayed after the suite has completed.
Example Test Suites
You can head over to the Peridot GitHub organization for plenty of examples using Peridot.
We would love to see other projects using Peridot, so if you have a project that uses it, we would love to know. Feel free to message us and let us know. We will gladly list your project on the site.
Running Peridot's tests
Peridot's tests were written using Peridot. After cloning Peridot, you can run tests using: