Created
December 5, 2013 19:55
-
-
Save acdcjunior/7812740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.rules.MethodRule; | |
import org.junit.runners.model.FrameworkMethod; | |
import org.junit.runners.model.Statement; | |
public class ExemploMethodRule implements MethodRule { | |
@Override | |
public Statement apply(final Statement base, FrameworkMethod method, Object target) { | |
System.out.println("ExemploMethodRule#apply() - base: " + base); | |
System.out.println("ExemploMethodRule#apply() - method (metodo de teste atual): " + method); | |
System.out.println("ExemploMethodRule#apply() - target (instancia atual da classe de teste): " + target); | |
return new Statement() { | |
@Override | |
public void evaluate() throws Throwable { | |
System.out.println("->before evaluate()"); | |
try { | |
base.evaluate(); | |
} finally { | |
System.out.println("->after evaluate()"); | |
} | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
will be available if you extendTestRule
isntead ofMethodRule
: