Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Extensions/RepeatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public function run(PHPUnit_Framework_TestResult $result = null)

//@codingStandardsIgnoreStart
for ($i = 1; $i <= $this->timesRepeat && !$result->shouldStop(); $i++) {
// Make the repeat count widely available.
$_ENV['PHPUnit_RepeatedTest_RepeatCount'] = $i;

if ($this->onlyRepeatFailed &&
$i > 1 &&
$this->test instanceof PHPUnit_Framework_TestCase &&
Expand Down
29 changes: 29 additions & 0 deletions tests/TextUI/repeat-onlyfailed-dataprovider.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
phpunit --repeat 3 --only-repeat-failed ../_files/DataProviderAlternateSuccessTest.php
--FILE--
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--repeat';
$_SERVER['argv'][3] = '3';
$_SERVER['argv'][4] = '--only-repeat-failed';
$_SERVER['argv'][5] = dirname(__FILE__).'/../_files/DataProviderAlternateSuccessTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit_TextUI_Command::main();
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

F.S.SS

Time: %s, Memory: %sMb

There was 1 failure:

1) DataProviderAlternateSuccessTest::testAlternateSuccess with data set #0 ('even')
Failed at run 1.

/Users/pieterdc/Sites/phpunit-kanooh/tests/_files/DataProviderAlternateSuccessTest.php:17

FAILURES!
Tests: 3, Assertions: 0, Failures: 1, Skipped: 3.
28 changes: 28 additions & 0 deletions tests/_files/DataProviderAlternateSuccessTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
class DataProviderAlternateSuccessTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerMethod
*/
public function testAlternateSuccess($succeedOddOrEven)
{
$repeatCount = 1;
if (array_key_exists('PHPUnit_RepeatedTest_RepeatCount', $_ENV)) {
// Alternate based on which repeat count we're currently at.
$repeatCount = $_ENV['PHPUnit_RepeatedTest_RepeatCount'];
}
if (($repeatCount + (int) ($succeedOddOrEven == 'even')) & 1) {
return;
} else {
$this->fail('Failed at run ' . $repeatCount . '.');
}
}

public static function providerMethod()
{
return array(
array('even'),
array('odd')
);
}
}