Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running PHPUnit test in PhpStorm adds "--teamcity" option causing error

I have the latest PhpStorm (2016.2) and PHPUnit phar (5.5.4). For some reason when I run a PHPUnit test in my project in PhpStorm, it is adding on --teamcity to the run command, resulting in a failure:

Testing started at 12:52 PM ...
Unit test suite invoked with a path to a non-unit test: --teamcity
Process finished with exit code 1

I have no idea where this --teamcity option is coming from, it happens no matter what test I run, and even when starting from a blank configuration. I also do NOT have the TeamCity plugin installed, I don't even use TeamCity.

Here's what the full command appears as:

/usr/local/Cellar/php70/7.0.9/bin/php /Users/name/bin/phpunit-5.5.4.phar --configuration /path/to/config/my-phpunit.xml ClassNameTest /Users/name/PhpstormProjects/path/to/tests/unit/app/ClassNameTest.php --teamcity

(sensitive information swapped out)

All I want to do is get rid of this --teamcity option, everything works if I run in a separate terminal window without that option. This only recently started happening, maybe after a PhpStorm update.

like image 833
Michael Butler Avatar asked Sep 20 '16 17:09

Michael Butler


3 Answers

tl;dr

I only could resolve this by removing the system installed phpunit instance from my system (Linux):

sudo apt remove phpunit-*

Details

Even if the setting in PhpStorm was to use composer autoloader: phpunit library should use composer

for some reason it ended up using TeamCity from /usr/share/php/PHPUnit/Util/Log/TeamCity.php: enter image description here

Project's local PHPUnit was 6.2 while the system default was 5.1 -> they're incompatible.

like image 169
Attila Fulop Avatar answered Nov 11 '22 19:11

Attila Fulop


I spent half a day struggling with this. The underlying issue is switching between PHPUnit versions (6.x.x -> 4.x.x). (Happened to me by switching branches)

A click on the refresh button in the PHPUnit preferences fixes it.

(Languages & Frameworks > PHP > PHPUnit)

Make sure the version of PHPUnit it thinks you have matches the one it reports.

screenshot

like image 38
stringerbell Avatar answered Nov 11 '22 21:11

stringerbell


This --teamcity option is used by PHPStorm to output tests result.

What you're facing is an issue caused by PHP7 and an old version of PHPUnit.

Remove your PHPUnit 5 and install the latest one (currently 6.2) with composer and use PHPUnit namespaces instead.

More info on this bug: https://github.com/sebastianbergmann/phpunit/issues/2460

like image 3
DevAntoine Avatar answered Nov 11 '22 19:11

DevAntoine