public LifecycleRule
This class is designed as a base class for test resources that provides multiple lifecycle hooks that combine JUnit's before/beforeClass and after/ afterClass by leveraging its @ClassRule/@Rule mechanism.
Since this class does not hold any state, it is implemented as an interface with default methods.
When using beforeSuite/afterSuite, make sure you use the same instance of your LifecycleRule subclass in both your suite and test classes.
| Modifier and Type | Method and Description |
|---|---|
void |
after()
override this method to add code that should be called after each test method
|
void |
afterClass()
override this method to add code that should be called before each test class or suite
|
void |
afterSuite()
override this method to add code that should be called before each test class or suite
|
org.junit.runners.model.Statement |
apply()
wraps the executed statement into a new statement that will call the appropriate lifecycle methods
|
void |
before()
override this method to add code that should be called before each test method
|
void |
beforeClass()
override this method to add code that should be called before each test class or suite
|
void |
beforeSuite()
override this method to add code that should be called before each test class or suite
|
boolean |
isClass() |
boolean |
isSuite() |
void |
onMethodFailure()
override this method to add code that should be called after each failed test method
|
void |
onMethodSuccess()
override this method to add code that should be called after each successful completion of a test method
|
org.junit.runners.model.Statement apply()
wraps the executed statement into a new statement that will call the appropriate lifecycle methods
boolean isClass()
boolean isSuite()
void beforeSuite()
override this method to add code that should be called before each test class or suite
void beforeClass()
override this method to add code that should be called before each test class or suite
void before()
override this method to add code that should be called before each test method
void onMethodSuccess()
override this method to add code that should be called after each successful completion of a test method
void onMethodFailure()
override this method to add code that should be called after each failed test method
void after()
override this method to add code that should be called after each test method
void afterClass()
override this method to add code that should be called before each test class or suite
void afterSuite()
override this method to add code that should be called before each test class or suite