-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Overview
A DisplayNameGenerator can access the type of a @Nested test class as well as the enclosing class in which a @Nested test class is declared, but it cannot access the concrete runtime type of the enclosing instance for a @Nested test class.
When a DisplayNameGenerator is used to build hierarchical display names, this can lead to confusing results or even conflicting results depending on the structure of the test classes used, "conflicting" in the sense that two nested test classes may have identical display names that do not represent the runtime structure of the test classes.
Example
@IndicativeSentencesGeneration
abstract class AbstractBaseTests {
@Nested
class NestedTests {
@Test
void test() {
}
}
}class ScenarioOneTests extends AbstractBaseTests {
}class ScenarioTwoTests extends AbstractBaseTests {
}Actual Behavior
When running ScenarioOneTests and ScenarioTwoTests, we currently see the following display names.
ScenarioOneTestsAbstractBaseTests, NestedTestsAbstractBaseTests, NestedTests, test()
ScenarioTwoTestsAbstractBaseTests, NestedTestsAbstractBaseTests, NestedTests, test()
Expected Behavior
When running ScenarioOneTests and ScenarioTwoTests, we would expect the following display names.
ScenarioOneTestsScenarioOneTests, NestedTestsScenarioOneTests, NestedTests, test()
ScenarioTwoTestsScenarioTwoTests, NestedTestsScenarioTwoTests, NestedTests, test()
Related Issues
Deliverables
- Ensure that a
DisplayNameGeneratorcan access the concrete runtime type of the enclosing instance for a@Nestedtest class.