Interesting Value Annotations

Interesting value annotations allow users to promote existing fields and methods to be identified and used in particular roles by Diffblue Cover when writing tests.

Using @InterestingTestFactory

Indicates the annotated method as a useful factory method for use in tests. Cover will automatically recognise factory methods that simply return a newly created instance, but may not identify more complicated factories. This annotation allows such factory methods to be manually annotated so that Cover considers them for producing inputs. For example the following method under test takes a User as input, but the User constructor is private and Cover doesn't naturally consider ofStaff(String) to be a safe factory method to call. By annotating the ofStaff(String) with @InterstingTestFactory we can tell Cover that this should be considered a good factory method to use in tests.

public String getUserDisplayString(User user) {
    if (user.manager) {
        return user.username + " (manager)";
    else {
        return user.username;

class User {
    private static Map<String, User> staff = new HashMap<String, User>();

    public static User ofStaff(String name) {
        return staff.computeIfAbsent(name, ignored -> new User(name, false));

    public final String username;
    public final boolean manager;

    private User(String username, boolean manager) {
        this.username = username;
        this.manager = manager;

Last updated