1
1
package org .junit .runners ;
2
2
3
- import static org .junit .internal .runners .rules .RuleMemberValidator .RULE_METHOD_VALIDATOR ;
4
- import static org .junit .internal .runners .rules .RuleMemberValidator .RULE_VALIDATOR ;
5
-
6
- import java .util .List ;
7
- import java .util .concurrent .ConcurrentHashMap ;
8
- import java .util .concurrent .TimeUnit ;
9
-
10
3
import org .junit .After ;
11
4
import org .junit .Before ;
12
5
import org .junit .Ignore ;
30
23
import org .junit .runners .model .MultipleFailureException ;
31
24
import org .junit .runners .model .Statement ;
32
25
26
+ import java .util .List ;
27
+ import java .util .concurrent .ConcurrentHashMap ;
28
+ import java .util .concurrent .TimeUnit ;
29
+
30
+ import static org .junit .internal .runners .rules .RuleMemberValidator .RULE_METHOD_VALIDATOR ;
31
+ import static org .junit .internal .runners .rules .RuleMemberValidator .RULE_VALIDATOR ;
32
+
33
33
/**
34
34
* Implements the JUnit 4 standard test case class model, as defined by the
35
35
* annotations in the org.junit package. Many users will never notice this
@@ -217,6 +217,14 @@ protected Object createTest() throws Exception {
217
217
return getTestClass ().getOnlyConstructor ().newInstance ();
218
218
}
219
219
220
+ /**
221
+ * Returns a new fixture to run a particular test {@code method} against.
222
+ * Default implementation executes the no-argument {@link #createTest()} method.
223
+ */
224
+ protected Object createTest (FrameworkMethod method ) throws Exception {
225
+ return createTest ();
226
+ }
227
+
220
228
/**
221
229
* Returns the name that describes {@code method} for {@link Description}s.
222
230
* Default implementation is the method's name
@@ -232,7 +240,7 @@ protected String testName(FrameworkMethod method) {
232
240
* Here is an outline of the default implementation:
233
241
*
234
242
* <ul>
235
- * <li>Invoke {@code method} on the result of {@code createTest()}, and
243
+ * <li>Invoke {@code method} on the result of {@link # createTest(org.junit.runners.model.FrameworkMethod )}, and
236
244
* throw any exceptions thrown by either operation.
237
245
* <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code
238
246
* expecting} attribute, return normally only if the previous step threw an
@@ -257,13 +265,13 @@ protected String testName(FrameworkMethod method) {
257
265
* This can be overridden in subclasses, either by overriding this method,
258
266
* or the implementations creating each sub-statement.
259
267
*/
260
- protected Statement methodBlock (FrameworkMethod method ) {
268
+ protected Statement methodBlock (final FrameworkMethod method ) {
261
269
Object test ;
262
270
try {
263
271
test = new ReflectiveCallable () {
264
272
@ Override
265
273
protected Object runReflectiveCall () throws Throwable {
266
- return createTest ();
274
+ return createTest (method );
267
275
}
268
276
}.run ();
269
277
} catch (Throwable e ) {
0 commit comments