From 5414368cb0e328fb9289d487f6c89c6a93b100d3 Mon Sep 17 00:00:00 2001 From: Peter Wright Date: Mon, 1 Dec 2014 21:53:18 +0000 Subject: [PATCH 1/3] Implementing #1036 - add BlockJUnit4ClassRunner#createTest(FrameworkMethod) to allow implementations to provide a custom instance of the test for each FrameworkMethod invocation --- .../org/junit/runners/BlockJUnit4ClassRunner.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java b/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java index 4d06199164e8..f9b418911fad 100644 --- a/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java +++ b/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java @@ -217,6 +217,14 @@ protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(); } + /** + * Returns a new fixture to run a particular test {@code method} against. + * Default implementation executes the no-argument {@link #createTest()} method. + */ + protected Object createTest(FrameworkMethod method) throws Exception { + return createTest(); + } + /** * Returns the name that describes {@code method} for {@link Description}s. * Default implementation is the method's name @@ -232,7 +240,7 @@ protected String testName(FrameworkMethod method) { * Here is an outline of the default implementation: * *