Skip to content

Commit a58faca

Browse files
committed
Add new annotation
This allows users to add a list of factory methods to supply different arguments to the methods under test.
1 parent 1cdf923 commit a58faca

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2024-2025 Diffblue Limited.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
package com.diffblue.cover.annotations;
16+
17+
import static java.lang.annotation.ElementType.METHOD;
18+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
19+
20+
import java.lang.annotation.Repeatable;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* Identifies factories that should be considered when writing tests for the annotated method.
26+
*
27+
* @since Diffblue Cover 2024.10.01
28+
*/
29+
@Retention(RUNTIME)
30+
@Target(METHOD)
31+
@Repeatable(InTestsUseFactory.Repeatable.class)
32+
public @interface InTestsUseFactory {
33+
34+
/** Collects multiple {@link InTestsUseFactory} annotations. */
35+
@Retention(RUNTIME)
36+
@Target(METHOD)
37+
@interface Repeatable {
38+
39+
/**
40+
* @return the repeated {@link InTestsUseFactory} annotations.
41+
*/
42+
InTestsUseFactory[] value();
43+
}
44+
45+
/**
46+
* @return The name of the class containing the factory methods.
47+
*/
48+
String className();
49+
50+
/**
51+
* @return The method names to use for factory methods.
52+
*/
53+
String[] methodNames();
54+
}

0 commit comments

Comments
 (0)