node package manager

grunt-phpunit

Grunt plugin for running phpunit.

grunt-phpunit

Grunt plugin for running phpunit.

This plugin requires Grunt 0.4.0.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins.

  1. Install this grunt plugin with the following command:

    npm install grunt-phpunit --save-dev
  1. Install phpunit (preferably with composer)

    composer install
  1. Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

    grunt.loadNpmTasks('grunt-phpunit');

Run this task with the grunt phpunit command.

phpunit: {
classes: {
dir: 'tests/php/'
},
options: {
bin: 'vendor/bin/phpunit',
bootstrap: 'tests/php/phpunit.php',
colors: true
}
}

Type: String

The directory where phpunit should be run, i.e. where the test classes and the bootstrap are located in.

Type: String Default: 'phpunit'

The executable binary.

Type: String Default: false

Log test execution in JUnit XML format to file.

Type: String Default: false

Log test execution in TAP format to file.

Type: String Default: false

Log test execution in JSON format.

Type: String Default: false

Generate code coverage report in Clover XML format.

Type: String Default: false

Generate code coverage report in HTML format.

Type: String Default: false

Serialize PHP_CodeCoverage object to file.

Type: Boolean Default: false

Generate code coverage report in text format. Default to writing to the standard output. This option can also be set by running the task with --coverage.

Type: String Default: false Filter which testsuite to run.

Type: String Default: false Only search for test in files with specified suffix(es).

Type: Boolean Default: false

Report test execution progress in TestDox format. This option can also be set by running the task with --testdox.

Type: String Default: false

Write agile documentation in HTML format to file.

Type: String Default: false

Write agile documentation in Text format to file.

Type: String Default: false

Filter which tests to run.

Type: String Default: false

Only runs tests from the specified group(s).

Type: String Default: false

Exclude tests from the specified group(s).

Type: Boolean Default: false

List available test groups. This option can also be set by running the task with --list-groups.

Type: String Default: false

TestSuiteLoader implementation to use.

Type: String Default: false

TestSuiteListener implementation to use.

Type: String Default: false

Runs the test(s) repeatedly.

Type: Boolean Default: false

Report test execution progress in TAP format. This option can also be set by running the task with --tap.

Type: Boolean Default: false

Use colors in output. This option can also be set by running the task with --colors.

Type: Boolean Default: false

Write to STDERR instead of STDOUT. This option can also be set by running the task with --stderr.

Type: Boolean Default: false

Stop execution upon first error. This option can also be set by running the task with --stop-on-error.

Type: Boolean Default: false

Stop execution upon first error or failure. This option can also be set by running the task with --stop-on-failure.

Type: Boolean Default: false

Stop execution upon first skipped test. This option can also be set by running the task with --stop-on-skipped.

Type: Boolean Default: false

Stop execution upon first incomplete test. This option can also be set by running the task with --stop-on-incomplete.

Type: Boolean Default: false

Run tests in strict mode. This option can also be set by running the task with --strict.

Type: Boolean Default: false

Output more verbose information. This option can also be set by running the task with --verbose.

Type: Boolean Default: false

Display debbuging information during test execution. This option can also be set by running the task with --debug.

Type: Boolean Default: false

Run each test in a separate PHP process. This option can also be set by running the task with --process-isolation.

Type: Boolean Default: false

Do not backup and restore $GLOBALS for each test. This option can also be set by running the task with --no-globals-backup.

Type: Boolean Default: false

Backup and restore static attributes for each test. This option can also be set by running the task with --static-backup.

Type: String Default: false

A "bootstrap" PHP file that is run before the tests.

Type: String Default: false

Read configuration from XML file.

Type: Boolean Default: false

Ignore default configuration file (phpunit.xml). This option can also be set by running the task with --no-configuration.

Type: String Default: false

Prepend PHP's include_path with given path(s).

Type: String Default: false

Sets a php.ini value.

Type: Boolean Default: false

Prints the output to the console immediately, instead of displaying the whole ouput at the end. This can be useful -combining with debug: true- when there are many long running tests.

Type: Boolean Default: false

Phpunit will return with exit code 1 when there are failed tests and wit exit code 2 when there are errors, and grunt will abort in this cases. When you want the task finish without aborting set failOnFailures to true.

Type: Integer Default: 200*1024

Configure the Node JS maxBuffer option passed to the exec function. This can be useful if you need to run a large test suite which outputs lot of logs, otherwise you could encounter a Fatal error: stdout maxBuffer exceeded. error. See issue #29 for more informations about this.