# Interesting Value Annotations

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

```java
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>();

    @InterestingTestFactory
    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;
    }
}
```


---

# 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-annotations/interesting-value-annotations.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.
