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).
Related
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.)
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. :)
I am learning building php unit tests using PHPUnit . There they have a manual and I encountered this example Where they use assertEmpty(), but when I run this code in command line I get this error : Call to undefined method StackTest::assertEmpty() in /var/www/.../tests/StackTest.php on line 20. So if this method is deprecated or something why they use it , also is there another method for this? (of course I can try this $this->assertEquals(0, count($stack));) but anyways...
The same with assertNotEmpty().
I'm on debian, and it looks like the default install of PHPunit is a bit old (3.4.14).
If you search for "assertEmpty" in this url, you will see what version it was added in (3.5.0-1).
http://packages.debian.org/changelogs/pool/main/p/phpunit/phpunit_3.6.10-1/changelog.html
What worked for me was removing phpunit from the system with apt, and installing it with pear
http://www.santiagolizardo.com/article/how-to-install-pear-and-phpunit-in-debianubuntu/57001
These links also helped me.
"Fatal error: Call to undefined method PHPUnit_Util_Filter::addfiletofilter() in /usr/bin/phpunit on line 48"
Cannot get PHPunit working
Are you running the unit test from the command line with the phpunit command line tools?
phpunit --verbose StackTest stacktest.php