Skip to content

Commit 99133c7

Browse files
committed
Move the README to root
1 parent d8b7a3e commit 99133c7

File tree

2 files changed

+130
-132
lines changed

2 files changed

+130
-132
lines changed

README.md

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,130 @@
1-
# testng-xml-formatter
2-
TestNG XML formatter for reporting Cucumber results
1+
[![Maven Central](https://img.shields.io/maven-central/v/io.cucumber/testng-xml-formatter.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.cucumber%22%20AND%20a:%22testng-xml-formatter%22)
2+
3+
⚠️ This is an internal package; you don't need to install it in order to use the TestNG XML Formatter.
4+
5+
TestNG XML Formatter
6+
===================
7+
8+
Writes Cucumber message into a TestNG XML report.
9+
10+
The TestNG XML report does not come with an XSD and the [TestNG documentations](https://testng-docs.readthedocs.io/testresults/#xml-reports)
11+
only provides a minimal example. Nevertheless, we had this formatter since 2013
12+
with no recent issues. So there is a good your tools will understand it.
13+
14+
If not, please let us know in the issues!
15+
16+
## Features and Limitations
17+
18+
### Test outcome mapping
19+
20+
Cucumber and the TestNG XML Report support a different set of test outcomes.
21+
These are mapped according to the table below.
22+
23+
Additionally, it is advisable to run Cucumber in strict mode. When used in
24+
non-strict mode scenarios with a pending or undefined outcome will not fail
25+
the test run ([#714](https://github.com/cucumber/common/issues/714)). This
26+
can lead to a xml report that contains `failure` outcomes while the build
27+
passes.
28+
29+
| Cucumber Outcome | XML Outcome | Passes in strict mode | Passes in non-strict mode |
30+
|------------------|-------------|-----------------------|---------------------------|
31+
| UNKNOWN | n/a | n/a | n/a |
32+
| PASSED | PASS | yes | yes |
33+
| SKIPPED | SKIP | yes | yes |
34+
| PENDING | FAIL | no | yes |
35+
| UNDEFINED | FAIL | no | yes |
36+
| AMBIGUOUS | FAIL | no | no |
37+
| FAILED | FAIL | no | no |
38+
39+
40+
### Step reporting
41+
42+
The TestNG XML report assumes that a test is a method on a class. Yet a scenario
43+
consists of multiple steps. To provide info about the failing step, the `message`
44+
element will contain a rendition of steps and their result.
45+
46+
```xml
47+
<exception class="AssertionError">
48+
<message><![CDATA[
49+
Given there are 12 cucumbers................................................passed
50+
When I eat 5 cucumbers......................................................passed
51+
Then I should have 7 cucumbers..............................................failed
52+
]]></message>
53+
<full-stacktrace>
54+
..the actual stack trace...
55+
</full-stacktrace>
56+
</exception>
57+
```
58+
59+
### Naming Rules and Examples
60+
61+
Cucumber does not require that scenario names are unique. To disambiguate
62+
between similarly named scenarios and examples the report prefixes the rule
63+
to the scenario or example name.
64+
65+
```feature
66+
Feature: Rules
67+
68+
Rule: a sale cannot happen if change cannot be returned
69+
Example: no change
70+
...
71+
Example: exact change
72+
...
73+
74+
Rule: a sale cannot happen if we're out of stock
75+
Example: no chocolates left
76+
...
77+
```
78+
79+
```xml
80+
<class name="Rules">
81+
<test-method name="a sale cannot happen if change cannot be returned - exact change" status="PASS"
82+
duration-ms="7" started-at="1970-01-01T00:00:00.001Z" finished-at="1970-01-01T00:00:00.008Z"/>
83+
<test-method name="a sale cannot happen if we're out of stock - no chocolates left" status="PASS"
84+
duration-ms="7" started-at="1970-01-01T00:00:00.001Z" finished-at="1970-01-01T00:00:00.008Z"/>
85+
</class>
86+
```
87+
88+
Likewise for example tables, the rule (if any), scenario outline name, example
89+
name, and number are included.
90+
91+
```feature
92+
Feature: Examples Tables
93+
94+
Scenario Outline: Eating cucumbers
95+
Given there are <start> cucumbers
96+
When I eat <eat> cucumbers
97+
Then I should have <left> cucumbers
98+
99+
Examples: These are passing
100+
| start | eat | left |
101+
| 12 | 5 | 7 |
102+
| 20 | 5 | 15 |
103+
104+
Examples: These are failing
105+
| start | eat | left |
106+
| 12 | 20 | 0 |
107+
| 0 | 1 | 0 |
108+
```
109+
110+
```xml
111+
<class name="Examples Tables">
112+
<test-method name="Eating cucumbers - These are passing - Example #1.1" status="PASS" duration-ms="7"
113+
started-at="1970-01-01T00:00:00.001Z" finished-at="1970-01-01T00:00:00.008Z"/>
114+
<test-method name="Eating cucumbers - These are passing - Example #1.2" status="PASS" duration-ms="7"
115+
started-at="1970-01-01T00:00:00.009Z" finished-at="1970-01-01T00:00:00.016Z"/>
116+
<test-method name="Eating cucumbers - These are failing - Example #2.1" status="FAIL" duration-ms="7"
117+
started-at="1970-01-01T00:00:00.017Z" finished-at="1970-01-01T00:00:00.024Z">
118+
<exception class="AssertionError">...</exception>
119+
</test-method>
120+
<test-method name="Eating cucumbers - These are failing - Example #2.2" status="FAIL" duration-ms="7"
121+
started-at="1970-01-01T00:00:00.025Z" finished-at="1970-01-01T00:00:00.032Z">
122+
<exception class="AssertionError">...</exception>
123+
</test-method>
124+
</class>
125+
```
126+
## Contributing
127+
128+
Each language implementation validates itself against the examples in the
129+
`testdata` folder. See the [testdata/README.md](testdata/README.md) for more
130+
information.

java/README.md

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

0 commit comments

Comments
 (0)