Created
March 21, 2017 13:30
-
-
Save magneticflux-/4c3478e21540b3f3652ec041752a36a3 to your computer and use it in GitHub Desktop.
Mockito TestRule replacement example
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.TestRule; | |
import org.junit.runner.Description; | |
import org.junit.runners.model.Statement; | |
import org.mockito.internal.configuration.IndependentAnnotationEngine; | |
import org.mockito.plugins.AnnotationEngine; | |
public class MockitoTestRule implements TestRule { | |
@Override | |
public Statement apply(Statement base, Description description) { | |
return new Statement() { | |
public void evaluate() throws Throwable { | |
AnnotationEngine annotationEngine = new IndependentAnnotationEngine(); | |
annotationEngine.process(description.getTestClass(), null); | |
base.evaluate(); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment