View Javadoc

1   package com.atlassian.selenium.junit4;
2   
3   import org.junit.runner.notification.RunNotifier;
4   import org.junit.runners.BlockJUnit4ClassRunner;
5   import org.junit.runners.model.InitializationError;
6   
7   /**
8    * A JUNIT 4 test runner that registers the {@link it.com.atlassian.applinks.CaptureScreenshotListener} before executing a test.
9    * This test runner can be applied by using the {@link org.junit.runner.RunWith} annotation on the test class.
10   *
11   * Example:
12   *
13   *    @RunWith(SeleniumJUnit4ClassRunner.class)
14   *    public class MySeleniumTest
15   *
16   * @since 2.0
17   */
18  public class SeleniumJUnit4ClassRunner extends BlockJUnit4ClassRunner
19  {
20      /**
21       * Creates a BlockJUnit4ClassRunner to run {@code klass}
22       *
23       * @throws org.junit.runners.model.InitializationError if the test class is malformed.
24       */
25      public SeleniumJUnit4ClassRunner(Class<?> klass) throws InitializationError
26      {
27          super(klass);
28      }
29  
30      @Override
31      public void run(final RunNotifier notifier)
32      {
33          CaptureScreenshotListener listener = new CaptureScreenshotListener();
34          notifier.addListener(listener);
35          super.run(notifier);
36          notifier.removeListener(listener);
37      }
38  }