Skip to content

Commit 3a1e730

Browse files
authored
Include pickle name if parameterized (#34)
Include the pickle name in the test name, if the pickle was parameterized. Fixes: #27, properly this time.
1 parent 8e5debe commit 3a1e730

10 files changed

+163
-94
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99
### Added
10+
- Include pickle name if parameterized [#34](https://github.com/cucumber/junit-xml-formatter/pull/34)
1011
- Support configurable `NamingStrategy.ExampleName` ([#32](https://github.com/cucumber/cucumber-junit-xml-formatter/pull/32), M.P. Korstanje)
1112

1213
## [0.4.0] - 2024-04-05

README.md

+20-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ Feature: Rules
7878
```
7979

8080
Likewise for example tables, the rule (if any), scenario outline name, example
81-
name, and number are included.
81+
name, and number are included. Additionally, if the scenario outline name is
82+
parameterized, the pickle name is included too.
8283

8384
```feature
8485
Feature: Examples Tables
@@ -97,13 +98,27 @@ Feature: Examples Tables
9798
| start | eat | left |
9899
| 12 | 20 | 0 |
99100
| 0 | 1 | 0 |
101+
102+
Scenario Outline: Eating <color> cucumbers
103+
Given I am transparent
104+
When I eat <color> cucumbers
105+
Then I become <color>
106+
107+
Examples:
108+
| color |
109+
| red |
110+
| green |
111+
| blue |
100112
```
101113

102114
```xml
103-
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.1" />
104-
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.2" />
105-
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.1" />
106-
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.2" />
115+
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.1" />
116+
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.2" />
117+
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.1" />
118+
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.2" />
119+
<testcase classname="Examples Tables" name="Eating &lt;color&gt; cucumbers - #1.1: Eating red cucumbers" />
120+
<testcase classname="Examples Tables" name="Eating &lt;color&gt; cucumbers - #1.2: Eating green cucumbers" />
121+
<testcase classname="Examples Tables" name="Eating &lt;color&gt; cucumbers - #1.3: Eating blue cucumbers" />
107122
```
108123
## Contributing
109124

java/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<dependency>
5757
<groupId>io.cucumber</groupId>
5858
<artifactId>query</artifactId>
59-
<version>[12.1.1,13.0.0)</version>
59+
<version>[12.2.0,13.0.0)</version>
6060
</dependency>
6161

6262
<dependency>

java/src/main/java/io/cucumber/junitxmlformatter/MessagesToJunitXmlWriter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MessagesToJunitXmlWriter implements AutoCloseable {
2727
private boolean streamClosed = false;
2828

2929
public MessagesToJunitXmlWriter(OutputStream out) {
30-
this(NamingStrategy.ExampleName.NUMBER, out);
30+
this(NamingStrategy.ExampleName.NUMBER_AND_PICKLE_IF_PARAMETERIZED, out);
3131
}
3232

3333
public MessagesToJunitXmlWriter(NamingStrategy.ExampleName exampleNameStrategy, OutputStream out) {

testdata/attachments.feature.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ When a JPEG image is attached...............................................pass
3535
When a PNG image is attached................................................passed
3636
]]></system-out>
3737
</testcase>
38-
<testcase classname="Attachments" name="Attaching images in an examples table - Example #1.1" time="0.005">
38+
<testcase classname="Attachments" name="Attaching images in an examples table - #1.1" time="0.005">
3939
<system-out><![CDATA[
4040
When a JPEG image is attached...............................................passed
4141
]]></system-out>
4242
</testcase>
43-
<testcase classname="Attachments" name="Attaching images in an examples table - Example #1.2" time="0.005">
43+
<testcase classname="Attachments" name="Attaching images in an examples table - #1.2" time="0.005">
4444
<system-out><![CDATA[
4545
When a PNG image is attached................................................passed
4646
]]></system-out>

testdata/examples-tables.feature.ndjson

+96-64
Large diffs are not rendered by default.

testdata/examples-tables.feature.xml

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuite name="Cucumber" time="0.049" tests="6" skipped="0" failures="4" errors="0">
3-
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.1" time="0.007">
2+
<testsuite name="Cucumber" time="0.073" tests="9" skipped="0" failures="4" errors="0">
3+
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.1" time="0.007">
44
<system-out><![CDATA[
55
Given there are 12 cucumbers................................................passed
66
When I eat 5 cucumbers......................................................passed
77
Then I should have 7 cucumbers..............................................passed
88
]]></system-out>
99
</testcase>
10-
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.2" time="0.007">
10+
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.2" time="0.007">
1111
<system-out><![CDATA[
1212
Given there are 20 cucumbers................................................passed
1313
When I eat 5 cucumbers......................................................passed
1414
Then I should have 15 cucumbers.............................................passed
1515
]]></system-out>
1616
</testcase>
17-
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.1" time="0.007">
17+
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.1" time="0.007">
1818
<failure type="AssertionError" message="Expected values to be strictly equal:
1919
2020
-8 !== 0
@@ -23,16 +23,16 @@ Then I should have 15 cucumbers.............................................pass
2323
2424
-8 !== 0
2525
26-
samples/examples-tables/examples-tables.feature:9
27-
samples/examples-tables/examples-tables.feature:20]]>
26+
samples/examples-tables/examples-tables.feature:14
27+
samples/examples-tables/examples-tables.feature:25]]>
2828
</failure>
2929
<system-out><![CDATA[
3030
Given there are 12 cucumbers................................................passed
3131
When I eat 20 cucumbers.....................................................passed
3232
Then I should have 0 cucumbers..............................................failed
3333
]]></system-out>
3434
</testcase>
35-
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.2" time="0.007">
35+
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.2" time="0.007">
3636
<failure type="AssertionError" message="Expected values to be strictly equal:
3737
3838
-1 !== 0
@@ -41,29 +41,50 @@ Then I should have 0 cucumbers..............................................fail
4141
4242
-1 !== 0
4343
44-
samples/examples-tables/examples-tables.feature:9
45-
samples/examples-tables/examples-tables.feature:21]]>
44+
samples/examples-tables/examples-tables.feature:14
45+
samples/examples-tables/examples-tables.feature:26]]>
4646
</failure>
4747
<system-out><![CDATA[
4848
Given there are 0 cucumbers.................................................passed
4949
When I eat 1 cucumbers......................................................passed
5050
Then I should have 0 cucumbers..............................................failed
5151
]]></system-out>
5252
</testcase>
53-
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - Example #3.1" time="0.007">
53+
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - #3.1" time="0.007">
5454
<failure/>
5555
<system-out><![CDATA[
5656
Given there are 12 cucumbers................................................passed
5757
When I eat banana cucumbers.................................................undefined
5858
Then I should have 12 cucumbers.............................................skipped
5959
]]></system-out>
6060
</testcase>
61-
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - Example #3.2" time="0.007">
61+
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - #3.2" time="0.007">
6262
<failure/>
6363
<system-out><![CDATA[
6464
Given there are 0 cucumbers.................................................passed
6565
When I eat 1 cucumbers......................................................passed
6666
Then I should have apple cucumbers..........................................undefined
6767
]]></system-out>
6868
</testcase>
69+
<testcase classname="Examples Tables" name="Eating cucumbers with &lt;friends&gt; friends - #1.1: Eating cucumbers with 11 friends" time="0.007">
70+
<system-out><![CDATA[
71+
Given there are 11 friends..................................................passed
72+
When there are 12 cucumbers.................................................passed
73+
Then each person can eat 1 cucumbers........................................passed
74+
]]></system-out>
75+
</testcase>
76+
<testcase classname="Examples Tables" name="Eating cucumbers with &lt;friends&gt; friends - #1.2: Eating cucumbers with 1 friends" time="0.007">
77+
<system-out><![CDATA[
78+
Given there are 1 friends...................................................passed
79+
When there are 4 cucumbers..................................................passed
80+
Then each person can eat 2 cucumbers........................................passed
81+
]]></system-out>
82+
</testcase>
83+
<testcase classname="Examples Tables" name="Eating cucumbers with &lt;friends&gt; friends - #1.3: Eating cucumbers with 0 friends" time="0.007">
84+
<system-out><![CDATA[
85+
Given there are 0 friends...................................................passed
86+
When there are 4 cucumbers..................................................passed
87+
Then each person can eat 4 cucumbers........................................passed
88+
]]></system-out>
89+
</testcase>
6990
</testsuite>

testdata/markdown.feature.md.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<testsuite name="Cucumber" time="0.021" tests="2" skipped="0" failures="1" errors="0">
3-
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - Example #1.1" time="0.009">
3+
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - #1.1" time="0.009">
44
<failure type="Error" message="You asked me to fail">
55
<![CDATA[You asked me to fail
66
samples/markdown/markdown.feature.md:24
@@ -13,7 +13,7 @@ When we use a data table and attach something and then fail.................fail
1313
Then this might or might not run............................................skipped
1414
]]></system-out>
1515
</testcase>
16-
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - Example #1.2" time="0.009">
16+
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - #1.2" time="0.009">
1717
<system-out><![CDATA[
1818
Given some TypeScript code:.................................................passed
1919
And some classic Gherkin:...................................................passed

testdata/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testdata/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "",
1010
"license": "ISC",
1111
"devDependencies": {
12-
"@cucumber/compatibility-kit": "^15.0.0",
12+
"@cucumber/compatibility-kit": "^15.1.0",
1313
"shx": "^0.3.4"
1414
}
1515
}

0 commit comments

Comments
 (0)