score:1
Accepted answer
as suggested by @matthewfarwell in the comments i implemented a test rule as per his answer
public static class retry implements testrule {
private final int retrycount;
public retry(int retrycount) {
this.retrycount = retrycount;
}
@override
public statement apply(final statement base,
final description description) {
return new statement() {
@override
@suppresswarnings("synthetic-access")
public void evaluate() throws throwable {
throwable caughtthrowable = null;
int failurescount = 0;
for (int i = 0; i < retrycount; i++) {
try {
base.evaluate();
} catch (throwable t) {
caughtthrowable = t;
system.err.println(description.getdisplayname()
+ ": run " + (i + 1) + " failed:");
t.printstacktrace();
++failurescount;
}
}
if (caughtthrowable == null) return;
throw new assertionerror(description.getdisplayname()
+ ": failures " + failurescount + " out of "
+ retrycount + " tries. see last throwable as the cause.", caughtthrowable);
}
};
}
}
as a nested class in my test class - and added
@rule
public retry retry = new retry(69);
before my test methods in the same class.
this indeed does the trick - it does repeat the test 69 times - in the case of some exception a new assertionerror, with an individual message containing some statistics plus the original throwable as a cause, gets thrown. so the statistics will be also visible in the junit view of eclipse.
Source: stackoverflow.com
Related Query
- Junit4 run a test class a fixed number of times and display results (eclipse)
- Run TestCase from java and display results on Eclipse JUnit view
- Inconsistent behavior with @EqualsAndHashCode between Eclipse JUnit4 and gradle test run
- Is there a way to make Eclipse run a JUnit test multiple times until failure?
- initializationError with Eclipse and JUNIT4 when executing a single test
- Eclipse Junit run configuration that takes the current selected test class as an arg?
- When and how does m2e use the Maven test scope to include test dependencies in Eclipse Run Configurations?
- Different kind of exception while i run test both eclipse and console?
- Why is this Java program gives incorrect results on Eclipse and correct results when run from terminal?
- Why is Eclipse reporting a JUnit compilation error when I can compile and run the test fine in a terminal?
- Junit 4 + Eclipse - Run inner class test cases with SpringJUnit4ClassRunner as well
- Eclipse (Helios) debugger - getting different Results in Debug mode and Run mode
- How to Test and Run a Client Server Program in C++ using Eclipse
- Why does my eclipse IDE run without compiler error when I create a non static inner class with static methods and variables?
- Getting Class Not found Exception when try to run test in eclipse
- How to set Run Configuration and Debug Configuration in Eclipse to choose the class that has the main method as the start-up class?
- Run JUnit tests dynamically and view results in eclipse JUnit view
- Run a JUnit test from an Eclipse Plugin and accessing the result
- Cannot run single unit test with JUnit and Eclipse for data-driven testing
- call a class and display the results
- Eclipse Luna and Class with Large number of methods
- Debugging eclipse unit test code "Test class should have exactly one" and "Workspace is closed" error
- How to configure External tool in Eclipse to run a jar file and load other class files?
- Eclipse does not start when I run it and results in an error
- How to run JUnit Test Classes in Java Main Application using Maven and Eclipse
- android sdk manager gives different results when run from eclipse and command line
- How to do a clean build in eclipse and run a junit test case at startup?
- how to run maven project in eclipse and display program output on console
- JUNIT Test class in Eclipse - java.lang.ClassNotFoundException
- Java - Build and run eclipse project from command line
More Query from same tag
- Mockito throwing java.lang.NoClassDefFoundError and java.lang.VerifyError
- Subclipse installed but no features appear in Eclipse 4.2 Juno
- How canI manually reload context in Eclipse?
- unable to debug errai-cdi quickstart
- android auto-language detection
- Installing JavaFX in Eclipse Luna
- How CMAKE_ECLIPSE_EXECUTABLE is used?
- Which subversive connector discovery to use
- Audio Record in pcm format Android eclipse
- Exporting a java project (in eclipse) to another computer
- java.lang.reflect.InvocationTargetException in javaFx
- toggle button to start a service
- RCP Export extension point schema reference document
- Why do I get a very long timeout in my PlayFramework app?
- How can i know an application running in debug or run mode in eclipse
- Eclipse, Maven: How to import the directory tree into the eclipse-workbench?
- The selected wizard could not be started in eclipse for Anltr 4 .How to solve?
- How to run spark-master with Eclipse, what am I doing wrong?
- Moving adMob ads to the bottom of Relative Layout crashes the app
- EGit: Issuing a fast-forward pull ~ How to configure fetch for a remote repository in EGit
- How to use private keys from Android storage
- Error: Could not find or load main class: Scala IDE/Spark
- Eclipse Tomcat Error 404
- For rooted android how to see application databases in File Explorer of Eclipse DDMS tool?
- Restarting a Java Program Within Eclipse
- cfscript Code Assist in CFBuilder
- Trying to call a service which plays looping background music at the load of splash screen Android
- <header> tag not recognized in eclipse
- Eclipse formatter and Double Brace Initialization
- Eclipse + PyDev says json.load() and json.dump() do not exist