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)"
    ```


---

Reply via email to