我扩展了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>
Inhttps://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.testsuites有这样的信息:
<测试套件>元素及其一个或多个<测试套件>儿童可以用于从测试套件和测试用例组成测试套件。
我在Magento中使用Ecomdev_PHPUnit
,它可以像你想要的那样进行子类,看看它的xml:
<testsuite name="Magento Test Suite">
<file>app/code/community/EcomDev/PHPUnit/Test/Suite.php</file>
</testsuite>
所以我想只要通过测试套件的完整路径就可以了!