Skip to content

Commit

Permalink
Include pickle name if parameterized
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 committed Jun 21, 2024
1 parent 8e5debe commit 97d2f82
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
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 <color> cucumbers - #1.1 - Eating red cucumbers" />
<testcase classname="Examples Tables" name="Eating <color> cucumbers - #1.2 - Eating green cucumbers" />
<testcase classname="Examples Tables" name="Eating <color> cucumbers - #1.3 - Eating blue cucumbers" />
```
## Contributing

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
12 changes: 6 additions & 6 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">
<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 @@ -32,7 +32,7 @@ When I eat 20 cucumbers.....................................................pass
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 @@ -50,15 +50,15 @@ When I eat 1 cucumbers......................................................pass
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
Expand Down
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

0 comments on commit 97d2f82

Please sign in to comment.