PHPUnit: jak spustit TestCase dvakrat za sebou rubrika: Programování: PHP
4
vojtech.kurka
položil/-a 15.8.2013
Ahoj,
potrebuju otestovat tridu, ktera ma debug (verbose) mod a chci otestovat oba mody. Trida musi davat stejny vysledek v normalnim i debug modu.
Nevite nahodou, jak spustit cely testcase dvakrat? Potrebuju neco jako:
run(); $testedClass->enableDebugMode(); run();
Zkousel jsem vytvorit testcase, ktery dedi od puvodniho testu a ma jen jinou setUp() metodu, ale PHPUnit ten puvodni testcase nespusti, spousti jen ten zdedeny.
Diky
odkaz
Vyřešeno
4
vojtech.kurka
odpověděl/-a 15.8.2013
Odpovim si sam, staci vhodny override metody 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); }
Pro zobrazení všech 3 odpovědí se prosím přihlaste:
Nebo se přihlaste jménem a heslem:
Komentáře