我正在使用Laravel,我只想运行一个测试文件,并且不想重命名或编辑所有测试代码,指定要忽略的内容的最方便的地方以及为我跑是phpunit.xml
所以我这样做:在phpunit.xml中忽略/ unignore测试
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<!--<directory>./tests/</directory>-->
<file>./tests/RunJustThisTest.php</file>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
正如你看到的我注释掉./tests/
文件夹,但它从所有文件都仍在运行这是荒谬的,我不知道,即使别的地方被越来越的PHPUnit该文件夹的路径?我只想运行/tests/RunJustThisTest.php
文件。我想在phpunit.xml
文件中指定它,而不是在代码中进行控制台或搞乱。
我在Netbeans中加载phpunit.xml文件。
"C:\xampp\php\php.exe" "C:\xampp\php\phpunit" "--colors" "--log-junit" "C:\Users\xxx\AppData\Local\Temp\nb-phpunit-log.xml" "--configuration" "C:\xampp\htdocs\yyy\phpunit.xml" "C:\Program Files\NetBeans 8.0.1\php\phpunit\NetBeansSuite.php" "--run=C:\xampp\htdocs\yyy\tests"
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.
你是如何调用PHPUnit的?通过IDE或控制台?你能否看到该命令正在读取配置文件(如果通过IDE)? – Katie
我编辑过的文章。加载Xml,如果我在xml中发出语法错误,它会报告它。 –
奇怪。我没有在你的xml中看到任何错误,所以我没有更多的想法,我甚至用我的配置加载你的例子,它工作正常。 (尽管经过PHPStorm)。抱歉,我无法提供更多帮助。您可以尝试在控制台中运行它以进一步了解行为。 – Katie