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
@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.
Last updated