Test naming

By default, test classes created by Diffblue Cover are named <CLASS_NAME>DiffblueTest and test methods are named test<INNER_CLASS_NAME><UNIT_NAME>. To change the naming, use the class-name-template and method-name-template options as detailed below.

Class name template

The --class-name-template="${CLASS_NAME}<string>" argument can be used to define the test class naming convention for tests written by Diffblue Cover. The ${CLASS_NAME} variable will be substituted with the name of the class under test.

Usage: --class-name-template="${CLASS_NAME}<string>"

Example: --class-name-template="${CLASS_NAME}Test"

Default: ${CLASS_NAME}DiffblueTest

Method name template

The --method-name-template="<string>\<variable>[\<variable>...]" argument can be used to define the test method naming convention for tests written by Diffblue Cover. Available variables are as follows:

  • The ${INNER_CLASS_NAME} variable will be 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.

  • The ${UNIT_NAME} variable will usually be 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.

  • The ${METHOD_NAME} variable will be substituted with the name of the first method under test, typically the only method under test.

  • To avoid duplication, do not use ${UNIT_NAME} and ${METHOD_NAME} together.

Usage: --method-name-template="<string>\<variable>[\<variable>...]"

Example: --method-name-template="aitest\${INNER_CLASS_NAME}\${METHOD_NAME}"

Default: test${INNER_CLASS_NAME}${UNIT_NAME}

For example, using the default naming convention for the method Something in inner class Foo, the test method will be named testFooSomething.

Disambiguation

Disambiguation between tests of the same name is performed automatically using sequential numbering:

@Test
public class testAppendTitle {
    ...
}

@Test
public class testAppendTitle2 {
    ...
}

Last updated