3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * A Decorator that runs a test repeatedly.
14 * @since Class available since Release 2.0.0
16 class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator
21 protected $processIsolation = false;
26 protected $timesRepeat = 1;
29 * @param PHPUnit_Framework_Test $test
30 * @param int $timesRepeat
31 * @param bool $processIsolation
33 * @throws PHPUnit_Framework_Exception
35 public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $processIsolation = false)
37 parent::__construct($test);
39 if (is_integer($timesRepeat) &&
41 $this->timesRepeat = $timesRepeat;
43 throw PHPUnit_Util_InvalidArgumentHelper::factory(
49 $this->processIsolation = $processIsolation;
53 * Counts the number of test cases that
54 * will be run by this test.
58 public function count()
60 return $this->timesRepeat * count($this->test);
64 * Runs the decorated test and collects the
65 * result in a TestResult.
67 * @param PHPUnit_Framework_TestResult $result
69 * @return PHPUnit_Framework_TestResult
71 * @throws PHPUnit_Framework_Exception
73 public function run(PHPUnit_Framework_TestResult $result = null)
75 if ($result === null) {
76 $result = $this->createResult();
79 //@codingStandardsIgnoreStart
80 for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) {
81 //@codingStandardsIgnoreEnd
82 if ($this->test instanceof PHPUnit_Framework_TestSuite) {
83 $this->test->setRunTestInSeparateProcess($this->processIsolation);
85 $this->test->run($result);