Class DisplayNameGenerator.IndicativeSentences

  • All Implemented Interfaces:
    DisplayNameGenerator
    Enclosing interface:
    DisplayNameGenerator

    @API(status=STABLE,
         since="5.10")
    public static class DisplayNameGenerator.IndicativeSentences
    extends java.lang.Object
    implements DisplayNameGenerator
    DisplayNameGenerator that generates complete sentences.

    This generator generates display names that build up complete sentences by concatenating the names of the test and the enclosing classes. The sentence fragments are concatenated using a separator. The separator and the display name generator for individual sentence fragments can be configured via the @IndicativeSentencesGeneration annotation.

    If you do not want to rely on a display name generator for individual sentence fragments, you can supply custom text for individual fragments via the @SentenceFragment annotation.

    Since:
    5.7
    • Constructor Detail

      • IndicativeSentences

        public IndicativeSentences()
    • Method Detail

      • generateDisplayNameForClass

        public java.lang.String generateDisplayNameForClass​(java.lang.Class<?> testClass)
        Description copied from interface: DisplayNameGenerator
        Generate a display name for the given top-level or static nested test class.

        If this method returns null, the default display name generator will be used instead.

        Specified by:
        generateDisplayNameForClass in interface DisplayNameGenerator
        Parameters:
        testClass - the class to generate a name for; never null
        Returns:
        the display name for the class; never blank
      • generateDisplayNameForNestedClass

        public java.lang.String generateDisplayNameForNestedClass​(java.util.List<java.lang.Class<?>> enclosingInstanceTypes,
                                                                  java.lang.Class<?> nestedClass)
        Description copied from interface: DisplayNameGenerator
        Generate a display name for the given @Nested inner test class.

        If this method returns null, the default display name generator will be used instead.

        Specified by:
        generateDisplayNameForNestedClass in interface DisplayNameGenerator
        Parameters:
        enclosingInstanceTypes - the runtime types of the enclosing instances for the test class, ordered from outermost to innermost, excluding nestedClass; never null
        nestedClass - the class to generate a name for; never null
        Returns:
        the display name for the nested class; never blank
      • generateDisplayNameForMethod

        public java.lang.String generateDisplayNameForMethod​(java.util.List<java.lang.Class<?>> enclosingInstanceTypes,
                                                             java.lang.Class<?> testClass,
                                                             java.lang.reflect.Method testMethod)
        Description copied from interface: DisplayNameGenerator
        Generate a display name for the given method.

        If this method returns null, the default display name generator will be used instead.

        Specified by:
        generateDisplayNameForMethod in interface DisplayNameGenerator
        Parameters:
        enclosingInstanceTypes - the runtime types of the enclosing instances for the test class, ordered from outermost to innermost, excluding testClass; never null
        testClass - the class the test method is invoked on; never null
        testMethod - method to generate a display name for; never null
        Returns:
        the display name for the test; never blank