小编DSh*_*hah的帖子

PHPUnit中的测试用例执行顺序

我已经定义了需要在phpunit.xml中按顺序执行的Test文件列表.

根据http://phpunit.de/manual/3.7/en/organizing-tests.html#organizing-tests.xml-configuration,提到测试用例的顺序可以定义为:

<phpunit>
  <testsuites>
    <testsuite name="Object_Freezer">
      <file>Tests/Freezer/HashGenerator/NonRecursiveSHA1Test.php</file>
      <file>Tests/Freezer/IdGenerator/UUIDTest.php</file>
      <file>Tests/Freezer/UtilTest.php</file>
      <file>Tests/FreezerTest.php</file>
      <file>Tests/Freezer/StorageTest.php</file>
      <file>Tests/Freezer/Storage/CouchDB/WithLazyLoadTest.php</file>
      <file>Tests/Freezer/Storage/CouchDB/WithoutLazyLoadTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>
Run Code Online (Sandbox Code Playgroud)

但似乎PHPUnit忽略了phpunit.xml中的配置并按字母顺序执行测试用例.

我想定义顺序只是因为我希望我的测试用例之一在最后执行.以下是我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit 
    colors="true" 
    stopOnFailure="false" 
    forceCoversAnnotation="true"
    bootstrap="../application/third_party/CIUnit/bootstrap_phpunit.php">
    <testsuites>
        <testsuite name="ModelTests">
            <directory suffix=".php">models</directory>
            <file>./models/aa.php</file>
            <file>./models/bb.php</file>
            <file>./models/cc.php</file>
            <file>./models/dd.php</file>
            <file>./models/ab.php</file>
            <file>./models/ac.php</file>
        </testsuite>
    </testsuites>
    <filter>
    <whitelist addUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">models</directory>
    </whitelist>
    </filter>
</phpunit>
Run Code Online (Sandbox Code Playgroud)

当我执行phpunit时它打印:从/var/www/builds/latest/tests/phpunit.xml读取配置

任何的想法?

php phpunit

9
推荐指数
1
解决办法
3681
查看次数

标签 统计

php ×1

phpunit ×1