Test Organization Annotations

Test organization annotations allow users to control how tests are organized and structured.

Using @WriteTestsTo

@WriteTestsTo annotation is available from cover-annotation version 1.9.0.

The @WriteTestsTo annotation directs Diffblue Cover to write tests for a specific source class into a designated test class file, rather than following the default naming template (configured via --class-name-template).

The specified test class name must be a valid ava classname, and the test class will be created (if it does not already exist) in the test folder under the same package structure as the source class.

circle-exclamation
package com.example.myapp;

@WriteTestsTo("CustomTestClassName")
public class SourceClass {
    public String getValue() {
        return "example";
    }
}
// Tests will be written to: src/test/java/com/example/myapp/CustomTestClassName.java
circle-info

This annotation can only be applied at the class level.

Last updated

Was this helpful?