Package com.axelor.test
Class GuiceRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- com.axelor.test.GuiceRunner
-
- All Implemented Interfaces:
org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Orderable,org.junit.runner.manipulation.Sortable
public class GuiceRunner extends org.junit.runners.BlockJUnit4ClassRunnerJUnit4 test runner that creates injector using the modules provided withGuiceModulesconfiguration.Here is a simple test:
@RunWith(GuiceRunner.class) @GuiceModules({MyModule.class}) public class MyTest { @Inject Foo foo; public void testFooInjected() { assertNotNull(foo); } }
-
-
Constructor Summary
Constructors Constructor Description GuiceRunner(Class<?> klass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcreateTest()protected InjectorgetInjector()Get the Guice injector.protected List<Module>getModules(Class<?> klass)voidrun(org.junit.runner.notification.RunNotifier notifier)protected voidvalidateZeroArgConstructor(List<Throwable> errors)-
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, computeTestMethods, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, withAfters, withBefores, withPotentialTimeout
-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Constructor Detail
-
GuiceRunner
public GuiceRunner(Class<?> klass) throws org.junit.runners.model.InitializationError
- Throws:
org.junit.runners.model.InitializationError
-
-
Method Detail
-
getModules
protected List<Module> getModules(Class<?> klass) throws org.junit.runners.model.InitializationError
- Throws:
org.junit.runners.model.InitializationError
-
run
public void run(org.junit.runner.notification.RunNotifier notifier)
- Overrides:
runin classorg.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
createTest
public Object createTest()
- Overrides:
createTestin classorg.junit.runners.BlockJUnit4ClassRunner
-
getInjector
protected Injector getInjector()
Get the Guice injector.- Returns:
- the injector
-
-