Package com._1c.g5.v8.dt.testing
Class JUnitGuiceRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- com._1c.g5.v8.dt.testing.JUnitGuiceRunner
-
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
,org.junit.runner.manipulation.Orderable
,org.junit.runner.manipulation.Sortable
public class JUnitGuiceRunner extends org.junit.runners.BlockJUnit4ClassRunner
JUnit runner for tests case with Google Guice.Clients may use annotation
GuiceModules
to configure google Guice injector for annotated class.
Runner will create injector with bindings form allGuiceModules.modules()
and then override them with allGuiceModules.overrides()
.Note, that Guice injector will be created once per test class.
Example of usage:
@RunWith(JUnitGuiceRunner.class) @GuiceModules( modules = { ModuleA.class, ModuleB.class, ModuleC.class }, overrides = { TestModuleA.class }) public class Test { @Inject private IServiceFromModuleA serviceFromModuleA; @Inject private IServiceFromModuleB serviceFromModuleB; @Test public void shouldTestSomething() { serviceFromModuleA.use(); serviceFromModuleB.use(); } }
Clients may also use
ParameterizedJUnitGuiceRunner
asJUnitGuiceRunner
alternative with ability to runparametrized
tests.- See Also:
GuiceModules
,ParameterizedJUnitGuiceRunner
-
-
Constructor Summary
Constructors Constructor Description JUnitGuiceRunner(Class<?> testClass)
Creates aJUnitGuiceRunner
to runtestClass
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
createTest()
-
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, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Constructor Detail
-
JUnitGuiceRunner
public JUnitGuiceRunner(Class<?> testClass) throws org.junit.runners.model.InitializationError
Creates aJUnitGuiceRunner
to runtestClass
.- Parameters:
testClass
- the test class for run, cannot benull
- Throws:
org.junit.runners.model.InitializationError
- if the test class is malformed
-
-