我正在寻找一种如何使用不同的设置多次运行测试用例的方法.
我正在测试一个数据库访问类(几十种测试方法),并希望在"正常模式"下测试它,然后在"调试模式"下测试它.两种模式都必须产生相同的测试结果.
在测试用例设置中是否有可能这样做?或者重写run()方法?我当然不想写两次测试:)
谢谢
编辑:GOT IT!
public function run(PHPUnit_Framework_TestResult $result = NULL)
{
if ($result === NULL) {
$result = $this->createResult();
}
/**
* Run the testsuite multiple times with different debug level
*/
$this->debugLevel = 0;
print "Setting debug level to: " . $this->debugLevel . PHP_EOL;
$result->run($this);
$this->debugLevel = 8;
print "Setting debug level to: " . $this->debugLevel . PHP_EOL;
$result->run($this);
$this->debugLevel = 16;
print "Setting debug level to: " . $this->debugLevel . PHP_EOL;
$result->run($this);
return $result;
}
public …Run Code Online (Sandbox Code Playgroud)