Skip to content

Commit 41cf132

Browse files
committed
TG-23049 - added new attributes to @InTestsMock
1 parent 8b85218 commit 41cf132

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

src/main/java/com/diffblue/cover/annotations/InTestsMock.java

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diffblue Limited.
2+
* Copyright 2024-2025 Diffblue Limited.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818
import static java.lang.annotation.ElementType.METHOD;
1919
import static java.lang.annotation.ElementType.PACKAGE;
2020
import static java.lang.annotation.ElementType.TYPE;
21-
import static java.lang.annotation.RetentionPolicy.CLASS;
21+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
2222

2323
import java.lang.annotation.Repeatable;
2424
import java.lang.annotation.Retention;
@@ -32,29 +32,54 @@
3232
*
3333
* @since Diffblue Cover 2024.04.02
3434
*/
35-
@Retention(CLASS)
35+
@Retention(RUNTIME)
3636
@Target({PACKAGE, TYPE, METHOD})
3737
@Repeatable(InTestsMock.Repeatable.class)
3838
public @interface InTestsMock {
3939

4040
/** Collects multiple {@link InTestsMock} annotations. */
41-
@Retention(CLASS)
41+
@Retention(RUNTIME)
4242
@Target({PACKAGE, TYPE, METHOD})
4343
@interface Repeatable {
4444

45-
/**
46-
* @return the repeated {@link InTestsMock} annotations.
47-
*/
45+
/** @return the repeated {@link InTestsMock} annotations. */
4846
InTestsMock[] value();
4947
}
5048

51-
/**
52-
* @return the classes to mock (or not).
53-
*/
49+
/** @return the classes to mock (or not). */
5450
Class<?>[] value();
5551

56-
/**
57-
* @return the mocking decision to apply.
58-
*/
52+
/** @return the mocking decision to apply. */
5953
MockDecision decision() default RECOMMENDED;
54+
55+
/** @return name of method to mock */
56+
// TODO this is a single string, but the value can have multiple classes. How do we map them?
57+
String method() default "";
58+
59+
/** @return boolean value or values to return from the {@link #method()} */
60+
boolean[] booleanReturnValues() default {};
61+
62+
/** @return byte value or values to return from the {@link #method()} */
63+
byte[] byteReturnValues() default {};
64+
65+
/** @return char value or values to return from the {@link #method()} */
66+
char[] charReturnValues() default {};
67+
68+
/** @return float value or values to return from the {@link #method()} */
69+
float[] floatReturnValues() default {};
70+
71+
/** @return double value or values to return from the {@link #method()} */
72+
double[] doubleReturnValues() default {};
73+
74+
/** @return int value or values to return from the {@link #method()} */
75+
int[] intReturnValues() default {};
76+
77+
/** @return long value or values to return from the {@link #method()} */
78+
long[] longReturnValues() default {};
79+
80+
/** @return short value or values to return from the {@link #method()} */
81+
short[] shortReturnValues() default {};
82+
83+
/** @return String value or values to return from the {@link #method()} */
84+
String[] stringReturnValues() default {};
6085
}

0 commit comments

Comments
 (0)