Skip to content

Commit ea25442

Browse files
Add tests
1 parent 59e7410 commit ea25442

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
#[Repeat] with JUnit XML logging records repetitions skipped after the failure threshold is reached
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$junitFile = tempnam(sys_get_temp_dir(), 'phpunit_repeat_junit_');
6+
7+
$_SERVER['argv'][] = '--no-configuration';
8+
$_SERVER['argv'][] = '--do-not-cache-result';
9+
$_SERVER['argv'][] = '--no-output';
10+
$_SERVER['argv'][] = '--log-junit';
11+
$_SERVER['argv'][] = $junitFile;
12+
$_SERVER['argv'][] = __DIR__ . '/_files/FailureThresholdReachedTest.php';
13+
14+
require __DIR__ . '/../../bootstrap.php';
15+
16+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
17+
18+
print file_get_contents($junitFile);
19+
20+
unlink($junitFile);
21+
--EXPECTF--
22+
<?xml version="1.0" encoding="UTF-8"?>
23+
<testsuites>
24+
<testsuite name="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest" file="%sFailureThresholdReachedTest.php" tests="5" assertions="2" errors="0" failures="2" skipped="3" time="%f">
25+
<testsuite name="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne" tests="5" assertions="2" errors="0" failures="2" skipped="3" time="%f">
26+
<testcase name="testOne (repetition 1 of 5)" file="%sFailureThresholdReachedTest.php" line="21" class="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest" classname="PHPUnit.TestFixture.Repeat.FailureThresholdReachedTest" assertions="1" time="%f">
27+
<failure type="PHPUnit\Framework\AssertionFailedError">PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne (repetition 1 of 5)%A
28+
Failure on repetition 1
29+
%A
30+
%sFailureThresholdReachedTest.php:26</failure>
31+
</testcase>
32+
<testcase name="testOne (repetition 2 of 5)" file="%sFailureThresholdReachedTest.php" line="21" class="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest" classname="PHPUnit.TestFixture.Repeat.FailureThresholdReachedTest" assertions="1" time="%f">
33+
<failure type="PHPUnit\Framework\AssertionFailedError">PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne (repetition 2 of 5)%A
34+
Failure on repetition 2
35+
%A
36+
%sFailureThresholdReachedTest.php:26</failure>
37+
</testcase>
38+
<testcase name="testOne (repetition 3 of 5)" file="%sFailureThresholdReachedTest.php" line="21" class="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest" classname="PHPUnit.TestFixture.Repeat.FailureThresholdReachedTest" assertions="0" time="%f">
39+
<skipped/>
40+
</testcase>
41+
<testcase name="testOne (repetition 4 of 5)" file="%sFailureThresholdReachedTest.php" line="21" class="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest" classname="PHPUnit.TestFixture.Repeat.FailureThresholdReachedTest" assertions="0" time="%f">
42+
<skipped/>
43+
</testcase>
44+
<testcase name="testOne (repetition 5 of 5)" file="%sFailureThresholdReachedTest.php" line="21" class="PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest" classname="PHPUnit.TestFixture.Repeat.FailureThresholdReachedTest" assertions="0" time="%f">
45+
<skipped/>
46+
</testcase>
47+
</testsuite>
48+
</testsuite>
49+
</testsuites>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
#[Repeat] with --log-teamcity reports repetitions skipped after the failure threshold is reached as ignored
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--no-configuration';
6+
$_SERVER['argv'][] = '--do-not-cache-result';
7+
$_SERVER['argv'][] = '--no-output';
8+
$_SERVER['argv'][] = '--log-teamcity';
9+
$_SERVER['argv'][] = 'php://stdout';
10+
$_SERVER['argv'][] = __DIR__ . '/_files/FailureThresholdReachedTest.php';
11+
12+
require __DIR__ . '/../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
##teamcity[testCount count='5' flowId='%d']
17+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest' locationHint='php_qn:%sFailureThresholdReachedTest.php::\PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest' flowId='%d']
18+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne' locationHint='php_qn:%sFailureThresholdReachedTest.php::\PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne' flowId='%d']
19+
##teamcity[testStarted name='testOne (repetition 1 of 5)' locationHint='php_qn:%sFailureThresholdReachedTest.php::\PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne (repetition 1 of 5)' flowId='%d']
20+
##teamcity[testFailed name='testOne (repetition 1 of 5)' message='Failure on repetition 1' details='%sFailureThresholdReachedTest.php:26|n' duration='%s' flowId='%d']
21+
##teamcity[testFinished name='testOne (repetition 1 of 5)' duration='%s' flowId='%d']
22+
##teamcity[testStarted name='testOne (repetition 2 of 5)' locationHint='php_qn:%sFailureThresholdReachedTest.php::\PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne (repetition 2 of 5)' flowId='%d']
23+
##teamcity[testFailed name='testOne (repetition 2 of 5)' message='Failure on repetition 2' details='%sFailureThresholdReachedTest.php:26|n' duration='%s' flowId='%d']
24+
##teamcity[testFinished name='testOne (repetition 2 of 5)' duration='%s' flowId='%d']
25+
##teamcity[testIgnored name='testOne (repetition 3 of 5)' message='Remaining repetition skipped after failure in repetition 2' duration='%s' flowId='%d']
26+
##teamcity[testIgnored name='testOne (repetition 4 of 5)' message='Remaining repetition skipped after failure in repetition 2' duration='%s' flowId='%d']
27+
##teamcity[testIgnored name='testOne (repetition 5 of 5)' message='Remaining repetition skipped after failure in repetition 2' duration='%s' flowId='%d']
28+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest::testOne' flowId='%d']
29+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\Repeat\FailureThresholdReachedTest' flowId='%d']

0 commit comments

Comments
 (0)