public class MoonshineRule extends Object implements org.junit.rules.TestRule
rule which initializes Moonshine container.
It is better for your test class to extend MoonshineTest or have it
annotated with
@RunWith(MoonshineRunner.class). With
those solutions the test class is created using Guice injector.
Usage:
class Test {
@ClassRule
public static final MoonshineRule moonshine = new MoonshineRule();
@Rule
public MethodRule injections = moonshine.injectMembers(this);
}
| Modifier and Type | Field and Description |
|---|---|
static String |
TEST_CONFIG |
| Constructor and Description |
|---|
MoonshineRule(List<MoonshineConfigurator> configurators,
String... configs)
Initializes
Moonshine environment. |
MoonshineRule(MoonshineConfigurator configurator,
String... configs)
Initializes
Moonshine environment. |
MoonshineRule(String... configs)
Initializes
Moonshine environment. |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description method) |
com.google.inject.Injector |
getGlobalInjector()
Returns global
Injector. |
org.junit.rules.MethodRule |
injectMembers(Object object)
Returns the rule which injects members of given object on each test run.
|
void |
setLoadTestConfigXml(boolean loadTestConfigXml) |
public static final String TEST_CONFIG
public MoonshineRule(String... configs)
Moonshine environment.
Usage:
class Test {
@ClassRule
public static final MoonshineRule moonshine = new MoonshineRule();
}
configs - resource path to the configuration files, by default
"/test-config.xml"public MoonshineRule(MoonshineConfigurator configurator, String... configs)
Moonshine environment.configurator - configurator for Moonshineconfigs - resource path to the configuration filespublic MoonshineRule(List<MoonshineConfigurator> configurators, String... configs)
Moonshine environment.configurators - list of configurators for Moonshineconfigs - resource path to the configuration filespublic void setLoadTestConfigXml(boolean loadTestConfigXml)
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description method)
apply in interface org.junit.rules.TestRulepublic com.google.inject.Injector getGlobalInjector()
Injector.public org.junit.rules.MethodRule injectMembers(Object object)
Usage:
class Test {
@ClassRule
public static final MoonshineRule moonshine = new MoonshineRule();
@Rule
public MethodRule injections = moonshine.injectMembers(this);
}
object - object to inject members intoCopyright © 2014 Atteo. All rights reserved.