Created
June 2, 2011 19:44
-
-
Save garyfleming/1005137 to your computer and use it in GitHub Desktop.
JUnit RepeatRule.java
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 java.math.BigDecimal; | |
import java.math.MathContext; | |
import java.math.RoundingMode; | |
import org.junit.rules.MethodRule; | |
import org.junit.runners.model.FrameworkMethod; | |
import org.junit.runners.model.Statement; | |
public class RepeatRule implements MethodRule { | |
private int times; | |
public RepeatRule(int times) { | |
this.times = times; | |
} | |
@Override | |
public Statement apply(final Statement base, final FrameworkMethod method, Object target) { | |
return new Statement() { | |
@Override | |
public void evaluate() throws Throwable { | |
for (int i = 0; i < times; i++) { | |
base.evaluate(); | |
} | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment