【问题标题】:Phpunit testsuite namePhpunit 测试套件名称
【发布时间】:2014-09-21 21:21:07
【问题描述】:

我使用 phpunit 和 webdriver。 在我的 test.php 文件中,我尝试从 phpunit.xml 文件中获取测试套件的名称。

<testsuites>
    <testsuite name="myTestsuite">
        <directory>./tests</directory>
    </testsuite>
</testsuites>

您知道,我如何访问测试套件名称?

【问题讨论】:

    标签: phpunit


    【解决方案1】:

    我认为目前不可能。

    我在 PHPUnit 存储库中创建了一个问题来讨论。 https://github.com/sebastianbergmann/phpunit/issues/4468

    【讨论】:

      【解决方案2】:

      您可以使用simplexml_load_file 加载文件并使用以下代码访问属性:

      $xml =  simplexml_load_file('phpunit.xml');
      echo $xml->testsuites->testsuite->attributes()->name;
      

      【讨论】:

      • 这不适用于多个测试套件 - 你不会知道你在哪个测试套件中。
      猜你喜欢
      • 2016-05-24
      • 2011-10-26
      • 2018-06-10
      • 2014-12-13
      • 1970-01-01
      • 2012-10-19
      • 1970-01-01
      • 2017-04-30
      • 2012-08-18
      相关资源
      最近更新 更多