public class JukitoRunner
extends org.junit.runners.BlockJUnit4ClassRunner
TestModule
. This last class will let you bind
TestSingleton
and TestEagerSingleton
and the runner will make sure these
singletons are reset at every invocation of a test case.
This code not very clean as it is cut & paste from
JUnit45AndHigherRunnerImpl
, but it's
unclear how we could make otherwise.
Most of the code here is inspired from: http://cowwoc.blogspot.com/2008/10/integrating-google-guice-into-junit4.
html
Depends on Mockito.Constructor and Description |
---|
JukitoRunner(Class<?> klass) |
Modifier and Type | Method and Description |
---|---|
protected List<org.junit.runners.model.FrameworkMethod> |
computeTestMethods() |
protected Object |
createTest() |
protected Injector |
getInjector()
Access the Guice injector.
|
protected org.junit.runners.model.Statement |
methodInvoker(org.junit.runners.model.FrameworkMethod method,
Object test) |
void |
run(org.junit.runner.notification.RunNotifier notifier) |
protected void |
validateInstanceMethods(List<Throwable> errors)
Adds to
errors for each method annotated with @Test ,
@Before , or @After that is not a public, void instance
method with no arguments. |
protected void |
validatePublicVoidMethods(Class<? extends Annotation> annotation,
boolean isStatic,
List<Throwable> errors)
Adds to
errors if any method in this class is annotated with
the provided annotation , but:
is not public, or
returns something other than void, or
is static (given isStatic is false ), or
is not static (given isStatic is true ). |
protected void |
validateTestMethods(List<Throwable> errors)
Adds to
errors for each method annotated with @Test that
is not a public, void instance method with no arguments. |
protected org.junit.runners.model.Statement |
withAfters(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement) |
protected org.junit.runners.model.Statement |
withBefores(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement) |
collectInitializationErrors, describeChild, getChildren, getTestRules, methodBlock, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateZeroArgConstructor, withPotentialTimeout
public JukitoRunner(Class<?> klass) throws org.junit.runners.model.InitializationError, InvocationTargetException, InstantiationException, IllegalAccessException
org.junit.runners.model.InitializationError
InvocationTargetException
InstantiationException
IllegalAccessException
public void run(org.junit.runner.notification.RunNotifier notifier)
run
in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
protected Object createTest() throws Exception
createTest
in class org.junit.runners.BlockJUnit4ClassRunner
Exception
protected org.junit.runners.model.Statement methodInvoker(org.junit.runners.model.FrameworkMethod method, Object test)
methodInvoker
in class org.junit.runners.BlockJUnit4ClassRunner
protected org.junit.runners.model.Statement withBefores(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement)
withBefores
in class org.junit.runners.BlockJUnit4ClassRunner
protected org.junit.runners.model.Statement withAfters(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement)
withAfters
in class org.junit.runners.BlockJUnit4ClassRunner
protected List<org.junit.runners.model.FrameworkMethod> computeTestMethods()
computeTestMethods
in class org.junit.runners.BlockJUnit4ClassRunner
protected void validateInstanceMethods(List<Throwable> errors)
errors
for each method annotated with @Test
,
@Before
, or @After
that is not a public, void instance
method with no arguments.validateInstanceMethods
in class org.junit.runners.BlockJUnit4ClassRunner
protected void validateTestMethods(List<Throwable> errors)
errors
for each method annotated with @Test
that
is not a public, void instance method with no arguments.validateTestMethods
in class org.junit.runners.BlockJUnit4ClassRunner
protected void validatePublicVoidMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors)
errors
if any method in this class is annotated with
the provided annotation
, but:
isStatic is false
), or
isStatic is true
).Copyright © 2010-2013 ArcBees Inc.. All Rights Reserved.