Package com._1c.g5.v8.dt.testing
Class ParameterizedJUnitGuiceRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters
-
- com._1c.g5.v8.dt.testing.ParameterizedJUnitGuiceRunner
-
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
,org.junit.runner.manipulation.Orderable
,org.junit.runner.manipulation.Sortable
public class ParameterizedJUnitGuiceRunner extends org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters
Parameterized JUnit runner for tests case with Google Guice. This runner is alternative toJUnitGuiceRunner
with ability to runparametrized
tests.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 parameter value.
Example of usage:
@RunWith(Parameterized.class) @UseParametersRunnerFactory(GuiceAwareParametersRunnerFactory.class) @GuiceModules( modules = { ModuleA.class, ModuleB.class, ModuleC.class }, overrides = { TestModuleA.class }) public class Test { @Inject private IServiceFromModuleA serviceFromModuleA; @Inject private IServiceFromModuleB serviceFromModuleB; @Parameter public String dataParameter; @Parameters public static String[] dataParameters() { return new String[] { "firstData", "secondData" }; } // this test will be executed two times, one time per data parameter @Test public void shouldTestSomething() { serviceFromModuleA.use(dataParameter); serviceFromModuleB.use(dataParameter); } }
- See Also:
GuiceModules
,Parameterized
,GuiceAwareParametersRunnerFactory
-
-
Constructor Summary
Constructors Constructor Description ParameterizedJUnitGuiceRunner(org.junit.runners.parameterized.TestWithParameters test)
Constructor ofParameterizedJUnitGuiceRunner
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
createTest()
-
Methods inherited from class org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters
classBlock, getName, getRunnerAnnotations, testName, validateConstructor, validateFields
-
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, computeTestMethods, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
-
-
-
-
Constructor Detail
-
ParameterizedJUnitGuiceRunner
public ParameterizedJUnitGuiceRunner(org.junit.runners.parameterized.TestWithParameters test) throws org.junit.runners.model.InitializationError
Constructor ofParameterizedJUnitGuiceRunner
.- Parameters:
test
- the test class, cannot benull
- Throws:
org.junit.runners.model.InitializationError
- if the test class is malformed
-
-