de.akquinet.jbosscc.needle.junit.testrule
Class NeedleTestRule
java.lang.Object
de.akquinet.jbosscc.needle.NeedleTestcase
de.akquinet.jbosscc.needle.junit.testrule.NeedleTestRule
- All Implemented Interfaces:
- org.junit.rules.TestRule
public class NeedleTestRule
- extends NeedleTestcase
- implements org.junit.rules.TestRule
JUnit TestRule for the initialization of the test. The Rule processes
and initializes all fields annotated with ObjectUnderTest.
This is an updated Rule to reflect the API change (MethodRule vs. TestRule)
in junit. Using this TestRule implementation has the drawback that the
calling test-instance has to be passed when the Rule is created, since the
new junit api does not pass the caller to the statement execution.
Using this Rule enables the RuleChains feature of junit >= 4.10.
Example:
public class UserDaoBeanTest {
@Rule
public final NeedleTestRule needle = new NeedleTestRule(this);
@ObjectUnderTest
private UserDaoBean userDao;
@Test
public void test() {
...
userDao.someAction();
...
}
}
- Author:
- Jan Galinski, Holisticon AG (jan.galinski@holisticon.de)
- See Also:
NeedleRule,
NeedleTestcase
|
Method Summary |
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NeedleTestRule
public NeedleTestRule(Object testInstance,
InjectionProvider<?>... injectionProvider)
- Parameters:
testInstance - - target of injectioninjectionProvider - - optional custom injection provider- See Also:
NeedleTestcase.NeedleTestcase(InjectionProvider...)
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
- Specified by:
apply in interface org.junit.rules.TestRule
Copyright © 2013 akquinet AG. All Rights Reserved.