Skip to content

Commit

Permalink
Include pickle name if parameterized (#34)
Browse files Browse the repository at this point in the history
Include the pickle name in the test name, if the pickle was parameterized.

Fixes: #27, properly this time.
  • Loading branch information
mpkorstanje authored Jun 22, 2024
1 parent 8e5debe commit 3a1e730
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 94 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

## [0.4.0] - 2024-04-05
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Feature: Rules
```

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

```feature
Feature: Examples Tables
Expand All @@ -97,13 +98,27 @@ Feature: Examples Tables
| start | eat | left |
| 12 | 20 | 0 |
| 0 | 1 | 0 |
Scenario Outline: Eating <color> cucumbers
Given I am transparent
When I eat <color> cucumbers
Then I become <color>
Examples:
| color |
| red |
| green |
| blue |
```

```xml
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.1" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.2" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.1" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.2" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.1" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.2" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.1" />
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.2" />
<testcase classname="Examples Tables" name="Eating &lt;color&gt; cucumbers - #1.1: Eating red cucumbers" />
<testcase classname="Examples Tables" name="Eating &lt;color&gt; cucumbers - #1.2: Eating green cucumbers" />
<testcase classname="Examples Tables" name="Eating &lt;color&gt; cucumbers - #1.3: Eating blue cucumbers" />
```
## Contributing

Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>query</artifactId>
<version>[12.1.1,13.0.0)</version>
<version>[12.2.0,13.0.0)</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class MessagesToJunitXmlWriter implements AutoCloseable {
private boolean streamClosed = false;

public MessagesToJunitXmlWriter(OutputStream out) {
this(NamingStrategy.ExampleName.NUMBER, out);
this(NamingStrategy.ExampleName.NUMBER_AND_PICKLE_IF_PARAMETERIZED, out);
}

public MessagesToJunitXmlWriter(NamingStrategy.ExampleName exampleNameStrategy, OutputStream out) {
Expand Down
4 changes: 2 additions & 2 deletions testdata/attachments.feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ When a JPEG image is attached...............................................pass
When a PNG image is attached................................................passed
]]></system-out>
</testcase>
<testcase classname="Attachments" name="Attaching images in an examples table - Example #1.1" time="0.005">
<testcase classname="Attachments" name="Attaching images in an examples table - #1.1" time="0.005">
<system-out><![CDATA[
When a JPEG image is attached...............................................passed
]]></system-out>
</testcase>
<testcase classname="Attachments" name="Attaching images in an examples table - Example #1.2" time="0.005">
<testcase classname="Attachments" name="Attaching images in an examples table - #1.2" time="0.005">
<system-out><![CDATA[
When a PNG image is attached................................................passed
]]></system-out>
Expand Down
160 changes: 96 additions & 64 deletions testdata/examples-tables.feature.ndjson

Large diffs are not rendered by default.

43 changes: 32 additions & 11 deletions testdata/examples-tables.feature.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Cucumber" time="0.049" tests="6" skipped="0" failures="4" errors="0">
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.1" time="0.007">
<testsuite name="Cucumber" time="0.073" tests="9" skipped="0" failures="4" errors="0">
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.1" time="0.007">
<system-out><![CDATA[
Given there are 12 cucumbers................................................passed
When I eat 5 cucumbers......................................................passed
Then I should have 7 cucumbers..............................................passed
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - Example #1.2" time="0.007">
<testcase classname="Examples Tables" name="Eating cucumbers - These are passing - #1.2" time="0.007">
<system-out><![CDATA[
Given there are 20 cucumbers................................................passed
When I eat 5 cucumbers......................................................passed
Then I should have 15 cucumbers.............................................passed
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.1" time="0.007">
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.1" time="0.007">
<failure type="AssertionError" message="Expected values to be strictly equal:
-8 !== 0
Expand All @@ -23,16 +23,16 @@ Then I should have 15 cucumbers.............................................pass
-8 !== 0
samples/examples-tables/examples-tables.feature:9
samples/examples-tables/examples-tables.feature:20]]>
samples/examples-tables/examples-tables.feature:14
samples/examples-tables/examples-tables.feature:25]]>
</failure>
<system-out><![CDATA[
Given there are 12 cucumbers................................................passed
When I eat 20 cucumbers.....................................................passed
Then I should have 0 cucumbers..............................................failed
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - Example #2.2" time="0.007">
<testcase classname="Examples Tables" name="Eating cucumbers - These are failing - #2.2" time="0.007">
<failure type="AssertionError" message="Expected values to be strictly equal:
-1 !== 0
Expand All @@ -41,29 +41,50 @@ Then I should have 0 cucumbers..............................................fail
-1 !== 0
samples/examples-tables/examples-tables.feature:9
samples/examples-tables/examples-tables.feature:21]]>
samples/examples-tables/examples-tables.feature:14
samples/examples-tables/examples-tables.feature:26]]>
</failure>
<system-out><![CDATA[
Given there are 0 cucumbers.................................................passed
When I eat 1 cucumbers......................................................passed
Then I should have 0 cucumbers..............................................failed
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - Example #3.1" time="0.007">
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - #3.1" time="0.007">
<failure/>
<system-out><![CDATA[
Given there are 12 cucumbers................................................passed
When I eat banana cucumbers.................................................undefined
Then I should have 12 cucumbers.............................................skipped
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - Example #3.2" time="0.007">
<testcase classname="Examples Tables" name="Eating cucumbers - These are undefined because the value is not an {int} - #3.2" time="0.007">
<failure/>
<system-out><![CDATA[
Given there are 0 cucumbers.................................................passed
When I eat 1 cucumbers......................................................passed
Then I should have apple cucumbers..........................................undefined
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers with &lt;friends&gt; friends - #1.1: Eating cucumbers with 11 friends" time="0.007">
<system-out><![CDATA[
Given there are 11 friends..................................................passed
When there are 12 cucumbers.................................................passed
Then each person can eat 1 cucumbers........................................passed
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers with &lt;friends&gt; friends - #1.2: Eating cucumbers with 1 friends" time="0.007">
<system-out><![CDATA[
Given there are 1 friends...................................................passed
When there are 4 cucumbers..................................................passed
Then each person can eat 2 cucumbers........................................passed
]]></system-out>
</testcase>
<testcase classname="Examples Tables" name="Eating cucumbers with &lt;friends&gt; friends - #1.3: Eating cucumbers with 0 friends" time="0.007">
<system-out><![CDATA[
Given there are 0 friends...................................................passed
When there are 4 cucumbers..................................................passed
Then each person can eat 4 cucumbers........................................passed
]]></system-out>
</testcase>
</testsuite>
4 changes: 2 additions & 2 deletions testdata/markdown.feature.md.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Cucumber" time="0.021" tests="2" skipped="0" failures="1" errors="0">
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - Example #1.1" time="0.009">
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - #1.1" time="0.009">
<failure type="Error" message="You asked me to fail">
<![CDATA[You asked me to fail
samples/markdown/markdown.feature.md:24
Expand All @@ -13,7 +13,7 @@ When we use a data table and attach something and then fail.................fail
Then this might or might not run............................................skipped
]]></system-out>
</testcase>
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - Example #1.2" time="0.009">
<testcase classname="Cheese" name="Nom nom nom - Ylajali! - because we need more tables - #1.2" time="0.009">
<system-out><![CDATA[
Given some TypeScript code:.................................................passed
And some classic Gherkin:...................................................passed
Expand Down
14 changes: 7 additions & 7 deletions testdata/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testdata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@cucumber/compatibility-kit": "^15.0.0",
"@cucumber/compatibility-kit": "^15.1.0",
"shx": "^0.3.4"
}
}

0 comments on commit 3a1e730

Please sign in to comment.