本文介绍了如何运行特定的 phpunit xml 测试套件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how can i choose a specific testsuite to be executed?

config.xml:

<testsuites>
    <testsuite name="Library">
        <directory>library</directory>
    </testsuite>
    <testsuite name="XXX_Form">
        <file>library/XXX/FormTest.php</file>
        <directory>library/XXX/Form</directory>
    </testsuite>
</testsuites>
解决方案

Here's the code as if PHPUnit 3.7.13

$ phpunit --configuration config.xml --testsuite Library
$ phpunit --configuration config.xml --testsuite XXX_Form

If you want to run a group of the test suites then you can do this

<testsuites>
  <testsuite name="Library">
    <directory>library</directory>
  </testsuite>
  <testsuite name="XXX_Form">
    <file>library/XXX/FormTest.php</file>
    <directory>library/XXX/Form</directory>
  </testsuite>
  <testsuite name="Both">
    <directory>library</directory>
    <file>library/XXX/FormTest.php</file>
    <directory>library/XXX/Form</directory>
  </testsuite>
</testsuites>

Then

$ phpunit --configuration config.xml --testsuite Both

Unfortunately PHPUnit currently does not support nested testsuites like this

<testsuites>
    <testsuite name="Both">
      <testsuite name="Library">
        <directory>library</directory>
      </testsuite>
      <testsuite name="XXX_Form">
        <file>library/XXX/FormTest.php</file>
        <directory>library/XXX/Form</directory>
      </testsuite>
  </testsuite>
</testsuites>

So if you wanted to run groups of test suites this way you have to have xml configuration duplication!

这篇关于如何运行特定的 phpunit xml 测试套件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 14:20