1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit.rules;
2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.Rule;
4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.runners.model.FrameworkMethod;
5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.runners.model.Statement;
6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot/**
8b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * A MethodRule is an alteration in how a test method is run and reported.
9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Multiple {@link MethodRule}s can be applied to a test method. The
10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * {@link Statement} that executes the method is passed to each annotated
11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * {@link Rule} in turn, and each may return a substitute or modified
12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * {@link Statement}, which is passed to the next {@link Rule}, if any. For
13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * examples of how this can be useful, see these provided MethodRules,
14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * or write your own:
15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *
16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <ul>
17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link ErrorCollector}: collect multiple errors in one test method</li>
18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link ExpectedException}: make flexible assertions about thrown exceptions</li>
19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link ExternalResource}: start and stop a server, for example</li>
20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link TemporaryFolder}: create fresh files, and delete after test</li>
21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link TestName}: remember the test name for use during the method</li>
22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link TestWatchman}: add logic at events during method execution</li>
23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link Timeout}: cause test to fail after a set time</li>
24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *   <li>{@link Verifier}: fail test if object state ends up incorrect</li>
25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * </ul>
26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */
27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot@Deprecated
28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic interface MethodRule {
29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Modifies the method-running {@link Statement} to implement an additional
31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * test-running rule.
32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param base The {@link Statement} to be modified
34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param method The method to be run
35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param target The object on with the method will be run.
36b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @return a new statement, which may be the same as {@code base},
37b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * a wrapper around {@code base}, or a completely new Statement.
38b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
39b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	Statement apply(Statement base, FrameworkMethod method, Object target);
40b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}