How to run PHPUnit test suite with bootstrap file with phing?
My app structure:
application/
library/
tests/
application/
library/
bootstrap.php
phpunit.xml
build.xml
phpunit.xml:
<phpunit bootstrap="./bootstrap.php" colors="true">
<testsuite name="Application Test Suite">
<directory>./</directory>
</testsuite>
<filter>
<whitelist>
<directory
suffix=".php">../library/</directory>
<directory
suffix=".php">../application/</directory>
<exclude>
<directory
suffix=".phtml">../application/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
then:
cd /path/to/app/tests/
phpunit
#all test passed
But how do I run the tests from /path/to/app/ dir? The problem is, that the bootstrap.php depends on relative paths to library and application.
If I run phpunit --configuration tests/phpunit.xml /tests I got a bunch of file not found errors.
How do I write build.xml file for phing to run the tests the same way phpunit.xml does?
I Think the best way is to create an small PHP Script to initalize your Unit tests, iam doing the following:
In my phpunit.xml / bootstrap=”./initalize.php”
initalize.php
BaseTest.php
All my Unit tests are extending BaseTest Class, it works like a charm.