In older versions of phpunit you could turn off code coverage reporting with the flag: --no-coverage. This allowed our suite to run much faster on CI environments, etc. In the current stable version (5.4) I don't see this option in the docs. What's the current way to turn off code coverage?
The --no-coverage option might be missing from the documentation but it works for me.
It's still in PHPUnit's code as well, see Command.php:66 and Command.php:523.
I've created a tiny test project with 1 class and 1 test to try it out. I've enabled code coverage output (HTML) in the <logging> section of phpunit.xml.
Running phpunit without the option:
$ phpunit
PHPUnit 5.4.6 by Sebastian Bergmann and contributors.
[removed irrelevant output]
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ... done
Code coverage is being generated and outputted.
Running phpunit with the option:
$ phpunit --no-coverage
PHPUnit 5.4.6 by Sebastian Bergmann and contributors.
[removed irrelevant output]
OK (1 test, 1 assertion)
No code coverage generation. (The command ran faster too.)
Related
When I try to run a test in my PhpStorm I see this:
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
Warning: Invocation with class name is deprecated
This maybe a issue with how PhpStorm handle the PHPUnit autoloader script and expect to be the filename as same as test.
Any turnaround?
It's a warning, you can ignore it for the moment (for PHPUnit 8.5.x at very least).
https://youtrack.jetbrains.com/issue/WI-50201 -- it has been fixed for next PhpStorm versions already (next minor 2019.3.x and next major 2020.1).
I'm trying to test my files in PHP but I keep getting this error message:
"/Users/Nakazai/XAMPP/bin/php" "/Applications/NetBeans/phpunit-old.phar" "--colors" "--log-junit" "/var/folders/ll/twrzpc8j77d3npwp2m_137mm0000gn/T/nb-phpunit-log.xml" "/Applications/NetBeans/NetBeans 8.0.2.app/Contents/Resources/NetBeans/php/phpunit/NetBeansSuite.php" "--run=/Applications/MAMP/htdocs/bank1/Tests"
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
unrecognized option --run
Done.
Appreciate your help, folks!
PHPUnit do not has command --run which you used in last argument. Check your NetBeans configuration, maybe your IDE try to run PHPUnit older than 4 (actually is version 5) and you have installed newer version.
I'm trying PHPUnit to work on my Netbeans 8.0.2. I'm using Ubuntu 14.04 LTS.
I followed this documentation:
https://netbeans.org/kb/docs/php/phpunit.html
I've installed phpunit and it's skeleton generator, and followed through till step 5. But when I'm trying to test it, the test won't run. It always says "No tests executed." "Perhaps error ocurred, verify in Output Window."
I've checked the output window and it shows this:
"/usr/bin/php" "/usr/local/bin/phpunit" "--colors" "--log-junit" "/tmp/nb-phpunit-log.xml" "/usr/local/netbeans-8.0.2/php/phpunit/NetBeansSuite.php" "--run=/var/www/html/calculator/tests/calculatorTest.php"
PHPUnit 4.8.5 by Sebastian Bergmann and contributors.
unrecognized option --run
Done.
Do I miss something?
Go back to PHPUnit 4.7, if you can.
It seems that this is a problem in NetBeans 8.0.2. I found two bugs in their Bugzilla system related to the --run parameter.
Bug 254221
Bug 254276
It has been fixed, but is only available in the nightly builds, since 8.0.2 is the most current release.
I have a test suite running on PHPUnit using the PHPStorm IDE. But, one of the tests used to fail due to the following issue,
PHP Warning: Cannot modify header information - headers already sent by ...
I managed fixed that by adding the #runInSeparateProcess annotation.
I was able to run all the tests successfully in the terminal. But when I try to run the tests using the PHPStorm IDE, I end up getting the following error message -
PHPUnit_Framework_Exception : PHPUnit 4.2.5 by Sebastian Bergmann.
Usage: phpunit [options] UnitTest [UnitTest.php]
phpunit [options] <directory>
Code Coverage Options:
--coverage-clover <file> Generate code coverage report in Clover XML format.
...(basically prints out the output of phpunit --help)
This is seen only while running the same test that failed earlier with the header error message.
Please assist me to fix this issue. Any help will be greatly appreciated.
Thanks!
Finally managed to fix it! I removed the #runInSeparateProcess annotation for the test that was failing and also the --stderr option in the run configurations. Instead, I added stderr="true" option in the phpunit tag present in the phpunit.xml and it worked. Strange.
Thank you Ian Bytchek for your time and effort. :)
After a fresh symfony2 install i can run phpunit -c app/ and phpunit tests the included demo application: OK (1 test, 1 assertion).
But i receive no output (even with verbosity) when i run phpunit -c vendor/symfony/ as described here: http://symfony.com/doc/2.0/contributing/code/tests.html.
Does anyone know how to make this work?
PHPUnit: 3.6.2
PHP: 5.3.8
Symfony: 2.0.5
Testing twig, doctrine and other plugins works as expected (although doctrine tests fail for some reason).
If you have no output it's maybe because you configured php not to display errors.
You must install the vendors using the vendors.php script before lauching the Symfony test suite:
$ php vendor/symfony/vendors.php
Are you running the tests using the provided phpunit.xml.dist configuration file?
From your projects root directory:
$ phpunit --configuration app/phpunit.xml.dist vendor/symfony/tests
That should add an autoloader for vendors.