-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathTestSourceData.java
More file actions
85 lines (71 loc) · 2.31 KB
/
TestSourceData.java
File metadata and controls
85 lines (71 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package datadog.trace.api.civisibility.config;
import datadog.trace.util.HashingUtils;
import java.lang.reflect.Method;
import java.util.Objects;
import javax.annotation.Nullable;
/** Data needed to identify test definition source. */
public class TestSourceData {
public static final TestSourceData UNKNOWN = new TestSourceData(null, null);
@Nullable private final Class<?> testClass;
@Nullable private final Method testMethod;
/**
* The name of the test method. May not correspond to {@code testMethod.getName()} (for instance,
* in Spock the testMethod is generated at compile time and has a name that is different from the
* source code method name)
*/
@Nullable private final String testMethodName;
public TestSourceData(@Nullable Class<?> testClass, @Nullable Method testMethod) {
this(testClass, testMethod, testMethod != null ? testMethod.getName() : null);
}
public TestSourceData(
@Nullable Class<?> testClass, @Nullable Method testMethod, @Nullable String testMethodName) {
this.testClass = testClass;
this.testMethod = testMethod;
this.testMethodName = testMethodName;
}
@Nullable
public Class<?> getTestClass() {
return testClass;
}
@Nullable
public Method getTestMethod() {
return testMethod;
}
/**
* Returns the name of the test method. May not correspond to {@code testMethod.getName()} (for
* instance, in Spock the testMethod is generated at compile time and has a name that is different
* from the source code method name)
*/
@Nullable
public String getTestMethodName() {
return testMethodName;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TestSourceData that = (TestSourceData) o;
return Objects.equals(testClass, that.testClass)
&& Objects.equals(testMethod, that.testMethod)
&& Objects.equals(testMethodName, that.testMethodName);
}
@Override
public int hashCode() {
return HashingUtils.hash(testClass, testMethod, testMethodName);
}
@Override
public String toString() {
return "TestSourceData{"
+ "testClass="
+ testClass
+ ", testMethod="
+ testMethod
+ ", testMethodName="
+ testMethodName
+ '}';
}
}