Class DisplayNameGenerator.ReplaceUnderscores

All Implemented Interfaces:
DisplayNameGenerator
Enclosing interface:
DisplayNameGenerator

public static class DisplayNameGenerator.ReplaceUnderscores extends DisplayNameGenerator.Simple
DisplayNameGenerator that replaces underscores with spaces.

This generator extends the functionality of DisplayNameGenerator.Simple by replacing all underscores ('_') found in class and method names with spaces (' ').

  • Constructor Details

    • ReplaceUnderscores

      public ReplaceUnderscores()
  • Method Details

    • generateDisplayNameForClass

      public String generateDisplayNameForClass(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
      Overrides:
      generateDisplayNameForClass in class DisplayNameGenerator.Standard
      Parameters:
      testClass - the class to generate a name for; never null
      Returns:
      the display name for the class; never blank
    • generateDisplayNameForNestedClass

      public String generateDisplayNameForNestedClass(List<Class<?>> enclosingInstanceTypes, 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
      Overrides:
      generateDisplayNameForNestedClass in class DisplayNameGenerator.Standard
      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 String generateDisplayNameForMethod(List<Class<?>> enclosingInstanceTypes, Class<?> testClass, 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
      Overrides:
      generateDisplayNameForMethod in class DisplayNameGenerator.Simple
      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