Exemplo n.º 1
0
  /**
   * Deletes existing screenshots before creating new ones.
   *
   * @see org.junit.rules.TestWatcher#starting(org.junit.runner.Description)
   */
  @Override
  protected void starting(final Description description) {

    if ("on".equals(getPropertyValue("screenshots"))) {

      final TestCase currentTestCase = description.getAnnotation(TestCase.class);

      // if screenshots are enabled, and the output directory already
      // exists, then delete the existing screenshots first.

      final String screenshotDirectory = getPropertyValue("site.resources.output.screenshots");

      final File outputFolder = new File(screenshotDirectory + currentTestCase.id());
      if (outputFolder.exists()) {
        final File[] files = outputFolder.listFiles();
        for (final File file : files) {
          file.delete();
        }
      }
    }

    super.starting(description);
  }
Exemplo n.º 2
0
 @Override
 protected void starting(Description description) {
   super.starting(description);
   className = description.getClassName();
   memWatcher = new MemWatcher();
 }