forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JUnit4SpockMethod.java
49 lines (39 loc) · 1.23 KB
/
JUnit4SpockMethod.java
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
package org.testng.junit;
import java.lang.reflect.Method;
import org.junit.runner.Description;
import org.testng.internal.ConstructorOrMethod;
/** @deprecated - Support for Spock1.x series is being deprecated as of TestNG <code>7.6.2</code> */
@Deprecated
public class JUnit4SpockMethod extends ConstructorOrMethod {
private static final Class<?> SPOCK_SPEC_CLASS = getSpockSpecClass();
private static Class<?> getSpockSpecClass() {
try {
return Class.forName("spock.lang.Specification");
} catch (ClassNotFoundException e) {
return null;
}
}
public static boolean isSpockClass(Class<?> testClass) {
return JUnit4SpockMethod.SPOCK_SPEC_CLASS != null
&& JUnit4SpockMethod.SPOCK_SPEC_CLASS.isAssignableFrom(testClass);
}
private final Class<?> declaringClass;
private final String description;
public JUnit4SpockMethod(Description description) {
super((Method) null);
this.declaringClass = description.getTestClass();
this.description = description.getDisplayName();
}
@Override
public Class<?> getDeclaringClass() {
return declaringClass;
}
@Override
public String getName() {
return description;
}
@Override
public String toString() {
return getName();
}
}