public interface MethodRule
MethodRules can be applied to a test method. The
Statement that executes the method is passed to each annotated
Rule in turn, and each may return a substitute or modified
Statement, which is passed to the next Rule, if any. For
examples of how this can be useful, see these provided MethodRules,
or write your own:
ErrorCollector: collect multiple errors in one test methodExpectedException: make flexible assertions about thrown exceptionsExternalResource: start and stop a server, for exampleTemporaryFolder: create fresh files, and delete after testTestName: remember the test name for use during the methodTestWatchman: add logic at events during method executionTimeout: cause test to fail after a set timeVerifier: fail test if object state ends up incorrectMethodRule has been replaced by TestRule,
which has the added benefit of supporting class rules.| Modifier and Type | Method and Description |
|---|---|
Statement |
apply(Statement base,
FrameworkMethod method,
java.lang.Object target)
Modifies the method-running
Statement to implement an additional
test-running rule. |
Statement apply(Statement base, FrameworkMethod method, java.lang.Object target)
Statement to implement an additional
test-running rule.base - The Statement to be modifiedmethod - The method to be runtarget - The object on which the method will be run.base,
a wrapper around base, or a completely new Statement.