public interface MethodRule
MethodRules can be applied to a test method. The
Statementthat executes the method is passed to each annotated
Rulein 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 method
ExpectedException: make flexible assertions about thrown exceptions
ExternalResource: start and stop a server, for example
TemporaryFolder: create fresh files, and delete after test
TestName: remember the test name for use during the method
TestWatchman: add logic at events during method execution
Timeout: cause test to fail after a set time
Verifier: fail test if object state ends up incorrect
MethodRulehas been replaced by
TestRule, which has the added benefit of supporting class rules.
Statement apply(Statement base, FrameworkMethod method, Object target)
Statementto implement an additional test-running rule.
Statementto be modified
method- The method to be run
target- The object on with the method will be run.
base, a wrapper around
base, or a completely new Statement.