Reputation: 889
I just installed PHPUnit on OS X + MAMP. (My phpunit was installed in my MAMP folder, so I copied it to /usr/bin because I couldn't use the "phpunit" command in terminal without the path)
When I go to a new Symfony2 folder and I try phpunit -c App/
the tests start and I get a green confirmation that all tests passed.
PHPUnit 3.7.8 by Sebastian Bergmann.
Configuration read from
/Users/username/Dropbox/www/symfonydev/Symfony/App/phpunit.xml.dist
.
Time: 0 seconds, Memory: 15.50Mb
OK (1 test, 1 assertion)
But when I go to my own little Symfony2 project and execute the same command, nothing happens! He doesn't even load the phpunit.xml.dist. I get no output at all on my terminal window.
The test file, however, does exist and is readable, I can start it by explicitly specifying it on the command line of phpunit:
phpunit -c app/ src/MatchTracker/Bundle/Tests/Controller/AuthenticationControllerTest.php
and this works.
It seems that something is wrong with the phpunit.xml.dist. It's the default phpunit.xml.dist and I tried renaming it to phpunit.xml. But nothing happens. What could be the problem? I think he can't find my xml or use it, or maybe he can read the phpunit.xml but doesn't find my tests.
Here's an example from my terminal: You see that the phpunit command doesn't do anything, except when I specify the test file...
MacBook-Pro:www username$ ls
LICENSE app composer.json composer.lock composer.phar src vendor web
MacBook-Pro:www username$ ls app/
AppCache.php SymfonyRequirements.php cache console phpunit.xml.dist
AppKernel.php autoload.php check.php logs
Resources bootstrap.php.cache config phpunit.xml
MacBook-Pro:www username$ phpunit -c app/
MacBook-Pro:www username$ phpunit -c app/ src/MatchTracker/Bundle/Tests/Controller/AuthenticationControllerTest.php
PHPUnit 3.7.8 by Sebastian Bergmann.
Configuration read from /Users/username/Dropbox/www/matchtracker.be/www/app/phpunit.xml
F
Time: 1 second, Memory: 21.75Mb
There was 1 failure:
1) MatchTracker\Bundle\Tests\Controller\DefaultControllerTest::testIndex
Failed asserting that 404 matches expected 200.
/Users/username/Dropbox/www/matchtracker.be/www/src/MatchTracker/Bundle/Tests/Controller/AuthenticationControllerTest.php:28
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
MacBook-Pro:www username$
Upvotes: 1
Views: 3555
Reputation: 36241
What's in your phpunit.xml
? <testsuites>
section of this file tells phpunit which directories scan for tests.
Remember that phpunit.xml
overwrites phpunit.xml.dist
.
Look at the original phpunit.xml.dist file and either remove the phpunit.xml
or start by copying phpunit.xml.dist
into phpunit.xml
.
Upvotes: 2