@@ -24,7 +24,7 @@ For installation into a Maven project the `provided` scope is recommended so tha
2424 <dependency>
2525 <groupId>com.diffblue.cover</groupId>
2626 <artifactId>cover-annotations</artifactId>
27- <version>1.7 .0</version>
27+ <version>1.8 .0</version>
2828 <scope>provided</scope>
2929 </dependency>
3030</dependencies>
@@ -36,9 +36,9 @@ For installation into a Gradle project the `compileOnly` and `testImplementation
3636
3737```
3838dependencies {
39- compileOnly("com.diffblue.cover:cover-annotations:1.7 .0")
39+ compileOnly("com.diffblue.cover:cover-annotations:1.8 .0")
4040
41- testImplementation("com.diffblue.cover:cover-annotations:1.7 .0")
41+ testImplementation("com.diffblue.cover:cover-annotations:1.8 .0")
4242}
4343```
4444
@@ -301,3 +301,59 @@ class User {
301301}
302302```
303303
304+ #### Using ` @InTestsUseFactories `
305+
306+ The ` @InTestsUseFactories ` annotation allows the user to recommend specific factories to use in tests.
307+ This can be useful if Cover is not using the correct factory methods to construct objects.
308+
309+ Consider the following example. In the test sources, create a class ` Factory ` that is responsible for constructing
310+ ` Car ` objects from some external resource (such as a JSON file, or the like). If we annotate the ` CarPainter ` 's
311+ ` changeColor ` method with ` @InTestsUseFactories ` pointing to the ` Factory ` 's ` getFirstCar ` method, Cover will attempt
312+ to use that to create instances of ` Car ` objects for testing.
313+
314+ You are able to specify multiple method names in the annotation, as well as specifying it multiple times (you could
315+ specify a ` ColorFactory ` for instance).
316+
317+ ``` java
318+ public class CarFactory {
319+ private static final CarFactory INSTANCE = new CarFactory ();
320+ private final List<Car > cars;
321+
322+ private CarFactory () {
323+ // initialize the list of cars from some resource
324+ }
325+
326+ public static Car getFirstCar () {
327+ return INSTANCE . cars. get(0 );
328+ }
329+
330+ // and so on...
331+ }
332+ ```
333+
334+ ``` java
335+ import com.diffblue.cover.annotations.InTestsUseFactories ;
336+
337+ public class CarPainter {
338+ @InTestsUseFactories (className = " CarFactory" , methodNames = {" getFirstCar" })
339+ public static Car changeColor (Car car , Color color ) {
340+ car. setColor(color);
341+ return car;
342+ }
343+ }
344+ ```
345+
346+ ### Experimental Annotations
347+
348+ Experimental annotations should not be used in a production setting, but are
349+ included to allow Diffblue to perform experiments with new features.
350+
351+ > [ !NOTE]
352+ > The annotations in the ` experimental ` package can change at any time.
353+ >
354+ > Do not rely on them in production code!
355+
356+ #### Using ` @InTestsUseLLM `
357+
358+ Indicates that LLMs can be used in this context.
359+
0 commit comments