I found a solution.
On a Japanese site I found an interesting idea:
First I had to duplicate webroot/test.php
as webroot/phpunit.php
, and replace the last line:
--- a/webroot/test.php
+++ b/webroot/phpunit-bootstrap.php
@@ -86,4 +86,4 @@ if (Configure::read('debug') < 1) {
require_once CAKE . 'TestSuite' . DS . 'CakeTestSuiteDispatcher.php';
-CakeTestSuiteDispatcher::run();
+App::load('CakeTestSuiteCommand');
This makes it possible to use this as a bootstrap for PHPUnit.
Then you can create a phpunit.xml
to ease the testing process.
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" stopOnFailure="false" bootstrap="webroot/phpunit-bootstrap.php">
<testsuites>
<testsuite name="AllTests">
<directory suffix=".php">Test/Case</directory>
</testsuite>
</testsuites>
</phpunit>
Now I only need to add grunt-phpunit
config to my Gruntfile.js
:
phpunit: {
options: {
bin: 'phpunit',
configuration: 'phpunit.xml',
colors: true,
},
app: {
options: {
testsuite: 'AllTests',
},
},
}
Now if I run grunt phpunit
, (or configure grunt watch
to run the phpunit
task upon changes, and change a file) PHPUnit runs my tests.