[
https://issues.apache.org/jira/browse/SUREFIRE-1372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16285278#comment-16285278
]
ASF GitHub Bot commented on SUREFIRE-1372:
------------------------------------------
Github user mpkorstanje commented on the issue:
https://github.com/apache/maven-surefire/pull/150
> How is Description constructed now by Cucumber?
Executing cucumber while using JUnit creates a tree of Descriptions like so:
```
Cucumber
|- Feature 1
| | - Scenario 1
| | - Scenario 2
| | - Scenario 3
|- Feature 2
| | - Scenario 4
| | - Scenario 5
| | - Scenario 6
```
The root description describes the [Cucumber JUnit
runner](https://github.com/cucumber/cucumber-jvm/blob/v2.2.0/junit/src/main/java/cucumber/api/junit/Cucumber.java)
and is created in [JUnits
ParentRunner](https://github.com/junit-team/junit4/blob/r4.12/src/main/java/org/junit/runners/ParentRunner.java#L349).
using
[Description.createSuitDescription(String)](https://github.com/junit-team/junit4/blob/r4.12/src/main/java/org/junit/runner/Description.java#L44).
This results in a `Description` with `fUniqueId` equal to the name of the
runner. This is always the fqn of the JUnit test annotated with
`@RunWith(Cucumber.class)`.
The Feature Descriptions are created in the
[FeatureRunner](https://github.com/cucumber/cucumber-jvm/blob/v2.2.0/junit/src/main/java/cucumber/runtime/junit/FeatureRunner.java#L44)
using [Description.createSuitDescription(String,
Serializable)](https://github.com/junit-team/junit4/blob/r4.12/src/main/java/org/junit/runner/Description.java#L57).
The name is name of the, which is used for display purposes but otherwise
irrelevant. For the extra `Serializable` parameter we provide a
[FeatureId](https://github.com/cucumber/cucumber-jvm/blob/v2.2.0/junit/src/main/java/cucumber/runtime/junit/FeatureRunner.java#L105).
This results in a `Description` with `fUniqueId` equal to the `FeatureId` of
that feature. This `FeatureId` contains the features uri which will satisfy
equality between different (repeated) executions of the same test class.
The same reasoning applies to the creation of the scenario description.
Each `Description` is created with a `PickleId` that contains the uri of that
scenario. The actual implementation is slightly more complex so I'd like to
omit it for brevity.
As such we end up with:
```
Cucumber Description.fUniqueId =
"com.example.package.of.my.RunnerTest"
|- Feature 1 Description.fUniqueId =
FeatureId("path/to/my/cucumber.feature1")
| | - Scenario 1 Description.fUniqueId =
PickleId("path/to/my/cucumber.feature1:1")
| | - Scenario 2 Description.fUniqueId =
PickleId("path/to/my/cucumber.feature1:2")
| | - Scenario 3 Description.fUniqueId =
PickleId("path/to/my/cucumber.feature1:3")
|- Feature 2 Description.fUniqueId =
FeatureId("path/to/my/cucumber.feature2")
| | - Scenario 4 Description.fUniqueId =
PickleId("path/to/my/cucumber.feature2:1")
| | - Scenario 5 Description.fUniqueId =
PickleId("path/to/my/cucumber.feature2:2")
| | - Scenario 6 Description.fUniqueId =
PickleId("path/to/my/cucumber.feature2:3")
```
> Does it contain the real method name or it is a scenario text?
No. It does not contain a method name. A scenario does not have a
one-to-one mapping with any methods. Instead we use uri's to reference a
scenario. Note that if we were to rewrite the above suite of features to a
suite of JUnit tests, the underlying `Description` tree would have a similar
identity.
```
TestSuite Description.fUniqueId =
"com.example.package.of.my.TestSuite"
|- Feature 1 Description.fUniqueId =
"com.example.package.of.my.Feature1"
| | - Scenario 1 Description.fUniqueId =
"scenario1(com.example.package.of.my.Feature1)"
| | - Scenario 2 Description.fUniqueId =
"scenario2(com.example.package.of.my.Feature1)"
| | - Scenario 3 Description.fUniqueId =
"scenario3(com.example.package.of.my.Feature1)"
|- Feature 2 Description.fUniqueId =
"com.example.package.of.my.TestSuite"
| | - Scenario 4 Description.fUniqueId =
"scenario1(com.example.package.of.my.Feature2)"
| | - Scenario 5 Description.fUniqueId =
"scenario2(com.example.package.of.my.Feature2)"
| | - Scenario 6 Description.fUniqueId =
"scenario3(com.example.package.of.my.Feature2)"
```
> Rerunning failing tests fails in combination with
> Description#createSuiteDescription
> ------------------------------------------------------------------------------------
>
> Key: SUREFIRE-1372
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1372
> Project: Maven Surefire
> Issue Type: Bug
> Components: Maven Surefire Plugin
> Affects Versions: 2.20
> Reporter: M.P. Korstanje
> Assignee: Tibor Digana
> Fix For: 2.21.1
>
>
> When using surefire to rerun failing tests created by a Runner that uses
> {noformat}Description#createSuiteDescription{noformat} with a human readable
> name rather then a class name the following stack trace occurs:
> {code}
> org.apache.maven.surefire.testset.TestSetFailedException: Unable to create
> test class 'Scenario: Fail when running'
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:385)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:292)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
> Caused by: java.lang.ClassNotFoundException: Scenario: Fail when running
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:292)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)