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
@InterestingTestFactorypublic 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;
}
}Last updated
Was this helpful?

