2016-09-21 119 views
1

我正在使用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. 

enter image description here

+1

你是如何调用PHPUnit的?通过IDE或控制台?你能否看到该命令正在读取配置文件(如果通过IDE)? – Katie

+0

我编辑过的文章。加载Xml,如果我在xml中发出语法错误,它会报告它。 –

+1

奇怪。我没有在你的xml中看到任何错误,所以我没有更多的想法,我甚至用我的配置加载你的例子,它工作正常。 (尽管经过PHPStorm)。抱歉,我无法提供更多帮助。您可以尝试在控制台中运行它以进一步了解行为。 – Katie

回答

1

这是错误的Netbeans从2011年开始,他们说:“这是预期的行为,我会说,对于大部分的用户。”

这是参数--run=C:\xampp\htdocs\yyy\tests

如果有人围绕此做出解决方法,请分享。

Why Netbean ignore PHPUnit testsuite from the XML config?

https://netbeans.org/bugzilla/show_bug.cgi?id=199072

+1

这真是一个无赖,但我怀疑他们的想法是,大多数人想要在他们标记的文件夹中运行所有测试来进行测试。几年前我转向PhpStorm,所以我不记得您是否确实告诉NetBeans“*这是我的测试源文件夹”,就像您在PhpStorm中所做的一样。 –