# 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.

{% tabs %}
{% tab title="Windows" %}
**Usage:** `--class-name-template="${CLASS_NAME}<string>"`

**Example:** `--class-name-template="${CLASS_NAME}CreatedTest"`

**Default:** `${CLASS_NAME}DiffblueTest`
{% endtab %}

{% tab title="Linux/macOS" %}
**Usage:** `--class-name-template=\${CLASS_NAME}<string>`

**Example:** `--class-name-template=\${CLASS_NAME}CreatedTest`

**Default:** `${CLASS_NAME}DiffblueTest`
{% endtab %}
{% endtabs %}

{% hint style="info" %}
When using merge mode (`--merge`), the default class name template automatically changes to `${CLASS_NAME}Test` to enable merging into existing test classes. See [Merge Mode](/features/cover-cli/writing-tests/merge-mode.md) for details.
{% endhint %}

## 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.
* The `${GIVEN}` variable will be substituted with a summary of the conditions prior to the method(s) under test being called, or a blank string if no description is available.
* The `${WHEN}` variable will be substituted with a summary of the conditions when the method(s) under test are called, or a blank string if no description is available.
* The `${THEN}` variable will be substituted with a summary of the consequences the method(s) under test being called, or a blank string if no description is available.
* The `${_}` variable will be substituted with a `_` separator, or a blank string if there are no values to separate.
* To avoid duplication, do not use `${UNIT_NAME}` and `${METHOD_NAME}` together.

{% tabs %}
{% tab title="Windows" %}
**Usage:** `--method-name-template="<string><variable>[<variable>...]"`

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

**Default:** `test${INNER_CLASS_NAME}${UNIT_NAME}${_}${GIVEN}${_}${WHEN}${_}${THEN}`

For example, using the default naming convention for an inner class `Foo` with an `equals(Object)` and `hashCode()` implementation, a test method might be named `testFooEqualsAndHashCode_whenOtherIsEqual_thenReturnEqual`.
{% endtab %}

{% tab title="Linux/macOS" %}
**Usage:** `--method-name-template=<string><variable>[<variable>...]`

**Example:**\
`--method-name-template=testCreated\${INNER_CLASS_NAME}\${METHOD_NAME}`

**Default:** `test${INNER_CLASS_NAME}${UNIT_NAME}${_}${GIVEN}${_}${WHEN}${_}${THEN}`

For example, using the default naming convention for an inner class `Foo` with an `equals(Object)` and `hashCode()` implementation, a test method might be named `testFooEqualsAndHashCode_whenOtherIsEqual_thenReturnEqual`.
{% endtab %}
{% endtabs %}

## Disambiguation

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

```java
@Test
public class testAppendTitle {
    ...
}

@Test
public class testAppendTitle2 {
    ...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cover-docs-preview.diffblue.com/features/cover-cli/writing-tests/test-naming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
