Test Naming
Last updated
Last updated
Test classes and methods created by Diffblue Cover are named after the class and methods under test using configurable templates. To change the naming, go to Diffblue > Change Settings
in IntelliJ and update the Test Naming
section as needed.
Description: Used to define the test class naming convention for tests written by Diffblue Cover. The ${CLASS}
variable will be substituted with the name of the class under test.
Default: ${CLASS}DiffblueTest
Example: ${CLASS}CreatedTest
Description: Used to define the test method naming convention for tests written by Diffblue Cover. The following variables can be used:
${INNER}
- substituted with the name of the inner class for the method under test. If there's no inner class this will be an empty string.
${UNIT}
- usually substituted with the name of the method under test. Where the unit under test comprises multiple methods (getters and setters, equals and hash code) the more general unit under test name is used.
${METHOD}
- substituted with the name of the first method under test, typically the only method under test. To avoid duplication, do not use ${UNIT}
and ${METHOD}
together.
${GIVEN}
- substituted with a summary of the conditions before testing, or else blank.
${WHEN}
- substituted with a summary of the conditions under test, or else blank.
${THEN}
- substituted with a summary of the test's consequences, or else blank.
${_}
- substituted with an underscore, or blank if there are no values to separate.
Default: test${INNER}${UNIT}${_}${GIVEN}${_}${WHEN}${_}${THEN}
Example: aitest${INNER}${UNIT}
Descriptive ${GIVEN}
, ${WHEN}
and ${THEN}
summaries are populated when disambiguating multiple tests for the same method under test, and are added to the test method name up to a maximum of 80 characters. When descriptive test names are enabled they are additionally used to provide improved javadoc comments, and to provider clearer test display names when the test framework supports it.
When ${UNIT}
is describes a single method under test that has overloads then the method under test's arguments are additionally described.
Descriptive test names are enabled by default but can be disabled via the "Descriptive Test Names" setting.
Disambiguation between tests of the same name is performed automatically using sequential numbering: