From 2b39238ebe434a3dc2b31c2763400c7ccdd7c62e Mon Sep 17 00:00:00 2001 From: James Catto Date: Thu, 8 May 2025 09:35:55 +0100 Subject: [PATCH 1/2] TG-23049 - added new attributes to @InTestsMock --- .../cover/annotations/InTestsMock.java | 50 ++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/diffblue/cover/annotations/InTestsMock.java b/src/main/java/com/diffblue/cover/annotations/InTestsMock.java index 0f9b6b1..5fc0fd6 100644 --- a/src/main/java/com/diffblue/cover/annotations/InTestsMock.java +++ b/src/main/java/com/diffblue/cover/annotations/InTestsMock.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Diffblue Limited. + * Copyright 2024-2025 Diffblue Limited. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PACKAGE; import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.CLASS; +import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; @@ -32,29 +32,53 @@ * * @since Diffblue Cover 2024.04.02 */ -@Retention(CLASS) +@Retention(RUNTIME) @Target({PACKAGE, TYPE, METHOD}) @Repeatable(InTestsMock.Repeatable.class) public @interface InTestsMock { /** Collects multiple {@link InTestsMock} annotations. */ - @Retention(CLASS) + @Retention(RUNTIME) @Target({PACKAGE, TYPE, METHOD}) @interface Repeatable { - /** - * @return the repeated {@link InTestsMock} annotations. - */ + /** @return the repeated {@link InTestsMock} annotations. */ InTestsMock[] value(); } - /** - * @return the classes to mock (or not). - */ + /** @return the classes to mock (or not). */ Class[] value(); - /** - * @return the mocking decision to apply. - */ + /** @return the mocking decision to apply. */ MockDecision decision() default RECOMMENDED; + + /** @return name of method to mock */ + String method() default ""; + + /** @return boolean value or values to return from the {@link #method()} */ + boolean[] booleanReturnValues() default {}; + + /** @return byte value or values to return from the {@link #method()} */ + byte[] byteReturnValues() default {}; + + /** @return char value or values to return from the {@link #method()} */ + char[] charReturnValues() default {}; + + /** @return float value or values to return from the {@link #method()} */ + float[] floatReturnValues() default {}; + + /** @return double value or values to return from the {@link #method()} */ + double[] doubleReturnValues() default {}; + + /** @return int value or values to return from the {@link #method()} */ + int[] intReturnValues() default {}; + + /** @return long value or values to return from the {@link #method()} */ + long[] longReturnValues() default {}; + + /** @return short value or values to return from the {@link #method()} */ + short[] shortReturnValues() default {}; + + /** @return String value or values to return from the {@link #method()} */ + String[] stringReturnValues() default {}; } From e8a99844cfef6671d7f5a23f05e4d6e0368ad7ed Mon Sep 17 00:00:00 2001 From: James Catto Date: Wed, 28 May 2025 10:51:43 +0100 Subject: [PATCH 2/2] TG-23145 - bumped version to 1.5.0 --- README.md | 6 +++--- pom.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e98f519..570e232 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ For installation into a Maven project the `provided` scope is recommended so tha com.diffblue.cover cover-annotations - 1.4.0 + 1.5.0 provided @@ -36,9 +36,9 @@ For installation into a Gradle project the `compileOnly` and `testImplementation ``` dependencies { - compileOnly("com.diffblue.cover:cover-annotations:1.4.0") + compileOnly("com.diffblue.cover:cover-annotations:1.5.0") - testImplementation("com.diffblue.cover:cover-annotations:1.4.0") + testImplementation("com.diffblue.cover:cover-annotations:1.5.0") } ``` diff --git a/pom.xml b/pom.xml index 97786d6..3a51e16 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 4.0.0 com.diffblue.cover cover-annotations - 1.4.0 + 1.5.0 jar Cover Annotations