Skip to content

Commit d57e14c

Browse files
Improve test for JUnit XML logger
1 parent f5e1941 commit d57e14c

File tree

3 files changed

+91
-29
lines changed

3 files changed

+91
-29
lines changed

tests/TextUI/log-junit.phpt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
--TEST--
2+
phpunit --log-junit php://stdout StatusTest ../_files/StatusTest.php
3+
--FILE--
4+
<?php
5+
$_SERVER['argv'][1] = '--no-configuration';
6+
$_SERVER['argv'][2] = '--log-junit';
7+
$_SERVER['argv'][3] = 'php://stdout';
8+
$_SERVER['argv'][4] = 'StatusTest';
9+
$_SERVER['argv'][5] = __DIR__ . '/../_files/StatusTest.php';
10+
11+
require __DIR__ . '/../bootstrap.php';
12+
PHPUnit_TextUI_Command::main();
13+
?>
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
.FEIS.<?xml version="1.0" encoding="UTF-8"?>
18+
<testsuites>
19+
<testsuite name="StatusTest" file="%s/StatusTest.php" tests="4" assertions="2" failures="1" errors="1" time="%s">
20+
<testcase name="testSuccess" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="1" time="%s"/>
21+
<testcase name="testFailure" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="1" time="%s">
22+
<failure type="PHPUnit_Framework_ExpectationFailedException">StatusTest::testFailure
23+
Failed asserting that false is true.
24+
25+
%s/StatusTest.php:%d
26+
</failure>
27+
</testcase>
28+
<testcase name="testError" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
29+
<error type="PHPUnit_Framework_ExceptionWrapper">StatusTest::testError
30+
Exception:
31+
32+
%s/StatusTest.php:%d
33+
</error>
34+
</testcase>
35+
<testcase name="testRisky" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s"/>
36+
</testsuite>
37+
</testsuites>
38+
39+
40+
Time: %s, Memory: %s
41+
42+
There was 1 error:
43+
44+
1) StatusTest::testError
45+
Exception:
46+
47+
%s/StatusTest.php:%d
48+
49+
--
50+
51+
There was 1 failure:
52+
53+
1) StatusTest::testFailure
54+
Failed asserting that false is true.
55+
56+
%s/StatusTest.php:%d
57+
58+
FAILURES!
59+
Tests: 6, Assertions: 2, Errors: 1, Failures: 1, Skipped: 1, Incomplete: 1.

tests/TextUI/log-xml.phpt

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/_files/StatusTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
class StatusTest extends PHPUnit_Framework_TestCase
3+
{
4+
public function testSuccess()
5+
{
6+
$this->assertTrue(true);
7+
}
8+
9+
public function testFailure()
10+
{
11+
$this->assertTrue(false);
12+
}
13+
14+
public function testError()
15+
{
16+
throw new \Exception;
17+
}
18+
19+
public function testIncomplete()
20+
{
21+
$this->markTestIncomplete();
22+
}
23+
24+
public function testSkipped()
25+
{
26+
$this->markTestSkipped();
27+
}
28+
29+
public function testRisky()
30+
{
31+
}
32+
}

0 commit comments

Comments
 (0)