Hi regarding the question above, we are using JUnit Parametrized Test Runner for Selenium automation. We have some Base Test classes that we inherit from. In those we have a test watchman. What I want to know is if there is any way to pass code to that. Basically, if a test fails, I want to implement a global retry mechanism. However, some set up code made be required. If I am using Parametrized runner, it will not call BeforeClass again. I am running into issues where StaleElements are propagating and causing other tests to fail.
public class BaseTest{
@Rule
public MethodRule watchman= new TestWatchman() {
@Override
public void failed(Throwable e, FrameworkMethod method) {
//call retry code here, need to be able to pass a chunk of code
}
@Override
public void succeeded(FrameworkMethod method) {
watchedLog+= method.getName() + " " + "success!\n";
}
};
}
@RunWith(Parameterized.class)
public class Test extends BaseTest{
@BeforeClass
public static void beforeClass()
{
//set failure code
}
}
Will doing this How to Re-run failed JUnit tests immediately? call the before class again? and if it is a parametrized test, I don't want to run all of them over again. Just the failures.