为什么PhpStorm仅针对某些带有额外参数的测试运行测试(bootstrap,configuration)?

时间:2018-02-02 13:51:39

标签: phpunit phpstorm xdebug

我正在使用PhpStorm,对于一些PHPUnit测试,我可以右键单击左侧的文件菜单并运行一些测试,它可以工作。

在控制台中显示

  

/ usr / bin / php -dxdebug.coverage_enable = 1 / srv / live / vendor / phpunit / phpunit / phpunit --coverage-clover /home/me/.PhpStorm2017.3/system/coverage/live$StringTest。覆盖--bootstrap /srv/live/vendor/autoload.php --configuration /srv/live/phpunit.xml tests \ src \ CoreBundle \ Helper \ StringTest / srv / live / src / tests / src / CoreBundle / Helper / StringTest .php --teamcity

但是,当我右键单击并运行它时,对于另一个包中的其他测试,命令是

  

/ usr / bin / php /srv/live/src/tests/src/OtherBundle/Classes/Validator/StringLengthTest.php

并且测试无法运行。我得到一个类未找到错误,我将该属性归因于上面第一个版本中没有额外参数的命令。我注意到的另一件事是' Run测试覆盖范围'仅在菜单中右键单击时才可用于第一次测试。

这种差异源自哪里?

我的phpunit.xml文件是

<?xml version="1.0"?>
<phpunit cacheTokens="true"
         colors="true"
         stopOnError="false"
         stopOnFailure="false"
         stopOnIncomplete="false"
         stopOnSkipped="false"
         verbose="true"
         bootstrap="/srv/live/vendor/autoload.php">
         <php>
           <server name="KERNEL_DIR" value="app/" />
         </php>
         <testsuites>
             <testsuite name="Project Test Suite">
                <directory>/srv/live/src/tests</directory>
             </testsuite>
         </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="false">
            <directory suffix=".php">/srv/live/src/</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./web/phpunitLog/codeCoverage" charset="UTF-8"
             yui="true" highlight="true"
             lowUpperBound="50" highLowerBound="80"/>
        <log type="testdox-html" target="./web/phpunitLog/testdox.html" />
    </logging>
</phpunit>

File -> Settings -> Languages & Frameworks -> PHP -> Test Frameworks

enter image description here

你对我为什么可以运行一个测试而不是另一个测试有任何想法 - 我的意思是为什么参数的差异(例如-dxdebug.coverage_enable=1)?

php.ini文件未更改。

1 个答案:

答案 0 :(得分:1)

我找到了一个解决方案(不确定它是否最好)。

如果点击Run -> Edit Configurations

然后单击加号并添加新的PHPUnit配置,我可以选择测试不起作用的包。

现在,当我右键单击文件菜单时,phpunit会运行额外的参数。

问题是,我从来没有为正在进行的测试做到这一点,所以虽然我找到了让失败的测试工作的方法,但我并不完全清楚为什么我首先看到了差异。

感谢HunterFrazier让车轮动起来。

相关问题