-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run some tests repeatedly, they seem not to be stable
- Loading branch information
Frohwalt Egerer
committed
May 29, 2014
1 parent
55c7725
commit 0080681
Showing
5 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.notnoop.apns.utils.junit; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({java.lang.annotation.ElementType.METHOD}) | ||
public @interface Repeat { | ||
public abstract int count(); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/com/notnoop/apns/utils/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.notnoop.apns.utils.junit; | ||
|
||
|
||
import org.junit.rules.TestRule; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
|
||
public class RepeatRule implements TestRule { | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
Repeat repeat = description.getAnnotation(Repeat.class); | ||
if (repeat != null) { | ||
return new RepeatStatement(repeat.count(), base); | ||
} | ||
return base; | ||
} | ||
|
||
private static class RepeatStatement extends Statement { | ||
|
||
private final int count; | ||
private final Statement base; | ||
|
||
private RepeatStatement(int count, Statement base) { | ||
this.count = count; | ||
this.base = base; | ||
} | ||
|
||
@Override | ||
public void evaluate() throws Throwable { | ||
for (int i = count; i > 0; i--) { | ||
base.evaluate(); | ||
} | ||
} | ||
} | ||
} |