1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
package org.kuali.rice.test.runners; |
14 |
|
|
15 |
|
import java.lang.reflect.Method; |
16 |
|
|
17 |
|
import org.apache.commons.beanutils.MethodUtils; |
18 |
|
import org.junit.internal.runners.InitializationError; |
19 |
|
import org.junit.internal.runners.JUnit4ClassRunner; |
20 |
|
import org.junit.runner.notification.RunNotifier; |
21 |
|
import org.kuali.rice.test.MethodAware; |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
@since |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 10 |
Complexity Density: 0.56 |
|
30 |
|
public class RiceUnitTestClassRunner extends JUnit4ClassRunner { |
31 |
|
|
32 |
|
private Method currentMethod; |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
0
|
public RiceUnitTestClassRunner(final Class<?> testClass) throws InitializationError {... |
35 |
0
|
super(testClass); |
36 |
|
|
37 |
|
} |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
39 |
0
|
@Override... |
40 |
|
protected void invokeTestMethod(Method method, RunNotifier runNotifier) { |
41 |
0
|
this.currentMethod = method; |
42 |
0
|
try { |
43 |
|
|
44 |
0
|
super.invokeTestMethod(method, runNotifier); |
45 |
|
} finally { |
46 |
0
|
this.currentMethod = null; |
47 |
|
} |
48 |
|
} |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
50 |
0
|
@Override... |
51 |
|
protected Object createTest() throws Exception { |
52 |
0
|
Object test = super.createTest(); |
53 |
0
|
setTestName(test, currentMethod); |
54 |
0
|
setTestMethod(test, currentMethod); |
55 |
|
|
56 |
0
|
return test; |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
@link@link |
61 |
|
@param |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
63 |
0
|
protected void setTestMethod(Object test, Method method) {... |
64 |
0
|
try { |
65 |
0
|
if (test instanceof MethodAware) { |
66 |
0
|
((MethodAware) test).setTestMethod(method); |
67 |
|
} |
68 |
|
} catch (Exception e) { |
69 |
0
|
e.printStackTrace(); |
70 |
|
|
71 |
|
} |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
84 |
0
|
protected void setTestName(final Object test, final Method testMethod) {... |
85 |
0
|
try { |
86 |
0
|
String name = testMethod == null ? "" : testMethod.getName(); |
87 |
0
|
final Method setNameMethod = MethodUtils.getAccessibleMethod(test.getClass(), "setName", new Class[]{String.class}); |
88 |
0
|
if (setNameMethod != null) { |
89 |
0
|
setNameMethod.invoke(test, new Object[]{name}); |
90 |
|
} |
91 |
|
} catch (final Exception e) { |
92 |
|
|
93 |
|
} |
94 |
|
} |
95 |
|
|
96 |
|
} |