public class NinjaRunner
extends org.junit.runners.BlockJUnit4ClassRunner
NinjaRunner makes it easy to test DAOs and service objects. Service objects are generally the place where business logic executed. Each service object may be injected a lot of DAOs.
Suppose you have some service objects ,
without NinjaRunner , the only way to test service objects is to getInstance() of these DAOs
from Guice's injector and manually constructor-injecting to the service object
in NinjaTest's @Before method.
With NinjaRunner , you just add @RunWith(NinjaRunner.class) to your test class ,
and declare @Inject private ServiceObj serviceObj; and you'll get an
injected serviceObj. No more @Before methods.
Code Example :
@RunWith(NinjaRunner.class)
public class DataServiceTest {
@Inject private ServiceObj serviceObj;
@Test
public void testDataService() {
assert (serviceObj != null);
}
}
| Constructor and Description |
|---|
NinjaRunner(java.lang.Class<?> klass) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
createTest() |
collectInitializationErrors, computeTestMethods, describeChild, getChildren, getTestRules, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeoutCopyright © 2014. All Rights Reserved.