10
다른 설정으로 테스트 케이스를 여러 번 실행하는 방법을 찾고 있습니다.PHPUnit 테스트 케이스를 여러 번 실행하기
나는 데이터베이스 액세스 등급 (수십 가지 테스트 방법)을 테스트 중이며 "일반 모드"와 "디버그 모드"에서 테스트하려고합니다. 두 모드 모두 동일한 테스트 결과를 만들어야합니다.
테스트 케이스 설정에서이를 수행 할 가능성이 있습니까? 또는 run() 메서드를 재정의 하시겠습니까? 나는 물론, 두 번 테스트를 작성하지 않으 :
당신에게
편집 감사 : 알았어요!
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 function setUp()
{
parent::setUp();
$this->myclass->setOptions('debug', $this->debugLevel);
}
테스트 데이터 세트를 방출하는'@ dataProvider' 함수를보십시오. – Sven
사용법 dataProviders를 알고 있습니다 :) 클래스의 간단한 설정을 변경하고 모든 테스트 메소드를 다시 실행하기 만하면됩니다. 무언가 같이 : run(); $ class-> setDebug (true); 운영(); –
좋아, 나는 이것이 일반적인 경우가 아니라고 생각한다. 당신은 원래의 테스트 클래스를 확장하고'setUp()'에서 한가지를 변경하려고 시도 했습니까? 이것은 새로운 레이블 아래에 모든 테스트 코드를 상속해야하며 물건을 두 번 실행해야합니다. – Sven