Class ReplaceCamelCaseAndUnderscoreAndNumber
java.lang.Object
org.junit.jupiter.api.DisplayNameGenerator.Standard
org.junitpioneer.jupiter.displaynamegenerator.ReplaceCamelCaseAndUnderscoreAndNumber
- All Implemented Interfaces:
org.junit.jupiter.api.DisplayNameGenerator
public class ReplaceCamelCaseAndUnderscoreAndNumber
extends org.junit.jupiter.api.DisplayNameGenerator.Standard
A class extending DisplayNameGenerator.Standard.
This extension handles method names with CamelCase, underscore and numbers.
The aim is to simplify unit test display names. Instead of using this method annotation DisplayName, we can just use this class annotation DisplayNameGeneration and use that method annotation if needed.
This generator follows 3 rules:
- Each uppercase letter is turned into its lowercase value prepended by space.
- Each underscore is turned into space. Words bounded by underscores or just starting with underscore are not transformed. Usually these words represent classes, variables...
- Each number is prepended by space.
Usage example:
@DisplayNameGeneration(ReplaceCamelCaseAndUnderscoreAndNumber.class)
class ExampleTest {}
- Since:
- 2.3.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.DisplayNameGenerator
org.junit.jupiter.api.DisplayNameGenerator.IndicativeSentences, org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores, org.junit.jupiter.api.DisplayNameGenerator.Simple, org.junit.jupiter.api.DisplayNameGenerator.Standard -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.junit.jupiter.api.DisplayNameGeneratorFields inherited from interface org.junit.jupiter.api.DisplayNameGenerator
DEFAULT_GENERATOR_PROPERTY_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringgenerateDisplayNameForMethod(Class<?> testClass, Method testMethod) private booleanhasParameters(Method method) private StringMethods inherited from class org.junit.jupiter.api.DisplayNameGenerator.Standard
generateDisplayNameForClass, generateDisplayNameForNestedClass
-
Field Details
-
INSTANCE
public static final org.junit.jupiter.api.DisplayNameGenerator INSTANCE
-
-
Constructor Details
-
ReplaceCamelCaseAndUnderscoreAndNumber
private ReplaceCamelCaseAndUnderscoreAndNumber()
-
-
Method Details
-
generateDisplayNameForMethod
-
replaceCamelCaseAndUnderscoreAndNumber
-
formatCamelCase
-
hasParameters
-