Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JUnit] Make duplicate pickle names unique #2045

Merged
merged 3 commits into from Jul 9, 2020

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Jul 8, 2020

Individual examples do not have a unique name. And while a unique name is not
required by Junit, various integrations such as sbt-junit assume this the case.

By appending [#n] to a scenario name it becomes unique again. So JUnit 4s
output becomes:

A feature with scenario outlines
  A scenario outline #1
  A scenario outline #2
  A scenario outline #3
  A scenario outline #4

The #n was taken from JUnit 5 which renders examples as:

A feature with scenario outlines
  A scenario outline
    With some other text
      Example #1
      Example #2
    With some text
     Example #1
     Example #2

Fixes: cucumber/cucumber-jvm-scala#102

@coveralls
Copy link

coveralls commented Jul 8, 2020

Coverage Status

Coverage increased (+0.03%) to 86.23% when pulling f7707a1 on fix-102-make-pickle-names-unique into b2c3b0e on main.

@mpkorstanje mpkorstanje force-pushed the fix-102-make-pickle-names-unique branch 5 times, most recently from 2828077 to 2011ccd Compare July 8, 2020 20:54
Individual examples do not have a unique name. And while a unique name is not
required by Junit, various integrations such as sbt-junit assume this the case.

By appending ` [#n]` to a scenario name it becomes unique again. So JUnit 4s
output becomes:

```
A feature with scenario outlines
  A scenario outline #1
  A scenario outline #2
  A scenario outline #3
  A scenario outline #4
```

The `#n` was taken from JUnit 5 which renders examples as:

```
A feature with scenario outlines
  A scenario outline
    With some other text
      Example #1
      Example #2
    With some text
     Example #1
     Example #2
```

Fixes: cucumber/cucumber-jvm-scala#102
@mpkorstanje mpkorstanje force-pushed the fix-102-make-pickle-names-unique branch from 2011ccd to fc8b066 Compare July 8, 2020 20:55
@gaeljw
Copy link
Member

gaeljw commented Jul 9, 2020

I tested it in the context of sbt junit, it seems to work but the error is not very self explanatory:

[error] Test bdd.tests.XxxTest.initializationError failed: java.lang.NullPointerException: null, took 0.017 sec
[error]     at io.cucumber.junit.FileNameCompatibleNames.uniqueSuffix(FileNameCompatibleNames.java:29)
[error]     at io.cucumber.junit.FeatureRunner.lambda$new$0(FeatureRunner.java:52)

@mpkorstanje
Copy link
Contributor Author

It's not supposed to throw an error. :D

@mpkorstanje
Copy link
Contributor Author

@gaeljw found the problem. I moved the filter into the wrong stream.

@rhande-mdsol
Copy link

Hello @mpkorstanje Thanks for looking into this. Are you planning to release this change ?

@mpkorstanje
Copy link
Contributor Author

After you tell me that it fixes the problem. 😄

@rhande-mdsol
Copy link

rhande-mdsol commented Jul 9, 2020

Sorry @mpkorstanje I am still trying to publish this project / PR and use it in my application, as I never worked on Maven before. Apologies

Is there a way that I can download the dependency of this particular PR and test ? I mean just like how it downloads from maven repository ?

@gaeljw
Copy link
Member

gaeljw commented Jul 9, 2020

Works perfectly for me in the two cases:

  • "Regular" scenarios with same name
  • Scenario Outlines

Great work @mpkorstanje

@mpkorstanje mpkorstanje marked this pull request as ready for review July 9, 2020 14:13
@mpkorstanje mpkorstanje merged commit 6122f69 into main Jul 9, 2020
@mpkorstanje mpkorstanje deleted the fix-102-make-pickle-names-unique branch July 9, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cucumber Scala final output shows 0 failures even when a scenario fails
4 participants