0

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.

Community
  • 1
  • 1
CodyK
  • 3,426
  • 4
  • 36
  • 52
  • Can you explain what kind of code you would like to inject into TestWatchman. – Stefan Birkner Jun 03 '15 at 22:48
  • Log in code, other setup code. Virtually anything required, to retry the test. It could be anything. Force a WebDriver quit and re-open, (this happens in AfterClass but won't be called for a failed parametrized test). – CodyK Jun 04 '15 at 15:06

0 Answers0