簡體   English   中英

phpunit擴展測試套件

[英]phpunit extend test suite

我擴展了PHPUnit_Framework_TestSuite來覆蓋setUp和tearDown方法,因為我需要PHPUnit在一組測試之前和之后做一些操作。 (測試在多個TestCase類中。)

class MyTestSuite extends PHPUnit_Framework_TestSuite {

    protected function setUp()
    {
        //do some stuff before all tests are run
    }

    protected function tearDown()
    {
        //do some stuff after all tests are run
    }
}

如何在xml配置文件中告訴phpunit使用這個TestSuite類,然后將testCase類綁定到它? 我所能找到的只是這樣的例子,似乎沒有指定哪個測試套件類phpunit將使用。

<phpunit>
  <testsuites>
    <testsuite name="money">
      <file>tests/IntlFormatterTest.php</file>
      <file>tests/MoneyTest.php</file>
      <file>tests/CurrencyTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>

https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.testsuites中有以下信息:

<testsuites>元素及其一個或多個<testsuite>子元素可用於從測試套件和測試用例中組成測試套件。

我在Magento中使用Ecomdev_PHPUnit ,它可以像你想要的那樣進行子類化,看看它的xml:

<testsuite name="Magento Test Suite">
     <file>app/code/community/EcomDev/PHPUnit/Test/Suite.php</file>
</testsuite>

所以我想通過測試套件的完整路徑!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM