You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to use the annotations in your Maven project then the Diffblue repository and `cover-annotations` dependency will need to be added into your `pom.xml`:
8
+
</div>
11
9
12
-
```xml
13
-
<dependencies>
14
-
<dependency>
15
-
<groupId>com.diffblue.cover</groupId>
16
-
<artifactId>cover-annotations</artifactId>
17
-
<version>1.0.0</version>
18
-
</dependency>
19
-
</dependencies>
20
-
```
21
-
22
-
### Gradle
23
-
24
-
In order to use the annotations in your Gradle project then the Diffblue repository and `cover-annotations` dependency will need to be added into your `build.gradle`:
10
+
Cover Annotations allows users to annotate their Java codebase with advice on how best to test it.
11
+
In turn this can be used by [Diffblue Cover](https://diffblue.com/cover) to tune the tests it writes.
Cover Annotations is published in the [Maven central repository](https://central.sonatype.com/artifact/com.diffblue.cover/cover-annotations/overview).
16
+
In order to use the annotations simply add `cover-annotations` as a dependency to your project, for example copying the snippet for Maven or Gradle from the repository page.
Perhaps you have a method that Diffblue Cover is unable to test, and you think it could make more progress using `Mockito.mockConstruction(Random.class)`.
86
66
In this case you could annotate the method (or class, or package) to recommend mocking construction of `Random`:
Perhaps you have a method that Diffblue Cover is unable to test, and you think it could make more progress using `Mockito.mockStatic(UUID.class)`.
107
87
In this case you could annotate the method (or class, or package) to recommend mocking static methods of `UUID`:
@@ -122,13 +102,13 @@ public class ClassUnderTest {
122
102
> dcover create --mock-static ClassToMockStatic
123
103
> ```
124
104
125
-
## Custom Input Annotations
105
+
### Custom Input Annotations
126
106
127
107
Custom input annotations allow particular inputs to be recommended to Diffblue Cover when writing tests.
128
108
129
-
### Using `@InTestsUseEnum`
109
+
#### Using `@InTestsUseEnums`
130
110
131
-
The `@InTestsUseEnum` annotation allows the user to recommend specific `enum` literal values to use in tests.
111
+
The `@InTestsUseEnums` annotation allows the user to recommend specific `enum` literal values to use in tests.
132
112
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
133
113
134
114
```java
@@ -137,7 +117,7 @@ public static boolean isDateOrTimeBased(@InTestsUseEnums({"SECONDS", "YEARS", "F
137
117
}
138
118
```
139
119
140
-
### Using `@InTestsUseClasses`
120
+
####Using `@InTestsUseClasses`
141
121
142
122
The `@InTestsUseClasses` annotation allows the user to recommend specific `Class` literal values to use in tests.
143
123
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
@@ -149,7 +129,7 @@ public static boolean isAnnotation(@InTestsUseClasses(Nullable.class) Class<?> t
149
129
}
150
130
```
151
131
152
-
### Using `@InTestsUseStrings`
132
+
####Using `@InTestsUseStrings`
153
133
154
134
The `@InTestsUseStrings` annotation allows the user to recommend specific `String` values to use in tests.
155
135
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
@@ -164,7 +144,7 @@ public static boolean isDayRelatedSongTitle(@InTestsUseStrings({"I Don't Like Mo
164
144
}
165
145
```
166
146
167
-
### Using `@InTestsUseCharacters`
147
+
####Using `@InTestsUseCharacters`
168
148
169
149
The `@InTestsUseCharacters` annotation allows the user to recommend specific `char` values to use in tests.
170
150
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
@@ -182,7 +162,7 @@ public static Integer toNullableCodePoint(
182
162
}
183
163
```
184
164
185
-
### Using `@InTestsUseBytes`
165
+
####Using `@InTestsUseBytes`
186
166
187
167
The `@InTestsUseBytes` annotation allows the user to recommend specific `byte` values to use in tests.
188
168
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
The `@InTestsUseShorts` annotation allows the user to recommend specific `short` values to use in tests.
200
180
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
@@ -206,7 +186,7 @@ public static String toUpperHexString(@InTestsUseShorts((short)0xD1FF) short inp
206
186
}
207
187
```
208
188
209
-
### Using `@InTestsUseIntegers`
189
+
####Using `@InTestsUseIntegers`
210
190
211
191
The `@InTestsUseIntegers` annotation allows the user to recommend specific `int` values to use in tests.
212
192
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
@@ -218,7 +198,7 @@ public static String toUpperHexString(@InTestsUseIntegers(0xD1FFB) int input) {
218
198
}
219
199
```
220
200
221
-
### Using `@InTestsUseLongs`
201
+
####Using `@InTestsUseLongs`
222
202
223
203
The `@InTestsUseLongs` annotation allows the user to recommend specific `long` values to use in tests.
224
204
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
@@ -230,7 +210,7 @@ public static String toUpperHexString(@InTestsUseLongs(0xD1FFBL) long input) {
230
210
}
231
211
```
232
212
233
-
### Using `@InTestsUseFloats`
213
+
####Using `@InTestsUseFloats`
234
214
235
215
The `@InTestsUseFloats` annotation allows the user to recommend specific `float` values to use in tests.
236
216
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
The `@InTestsUseDoubles` annotation allows the user to recommend specific `double` values to use in tests.
248
228
Sometimes this can be useful to control the values used for cosmetic reasons, but it can also be useful when Cover is unable to identify values to cover all cases.
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.
260
240
261
-
### Using `@InterestingTestFactory`
241
+
####Using `@InterestingTestFactory`
262
242
263
243
Indicates the annotated method as a useful factory method for use in tests.
264
244
Cover will automatically recognise factory methods that simply return a newly created instance, but may not identify more complicated factories.
0 commit comments