private RunNotifier getRunNotifier(
     org.junit.runner.notification.RunListener main,
     Result result,
     List<org.junit.runner.notification.RunListener> others) {
   RunNotifier fNotifier = new RunNotifier();
   fNotifier.addListener(main);
   fNotifier.addListener(result.createListener());
   for (org.junit.runner.notification.RunListener listener : others) {
     fNotifier.addListener(listener);
   }
   return fNotifier;
 }
 private Result run(Runner runner) throws InitializationError {
   RunNotifier notifier = new RunNotifier();
   Result result = new Result();
   notifier.addListener(result.createListener());
   runner.run(notifier);
   return result;
 }
  @Override
  public void run(RunNotifier notifier) {
    if (shouldInitMocks) {
      // Allow Mockito to do its verification
      notifier.addListener(new FrameworkUsageValidator(notifier));
    }

    super.run(notifier);
  }
 @Override
 protected void startup(RemoteRunNotifier remote) throws Throwable {
   try {
     RunNotifier notifier = new RunNotifier();
     notifier.addListener(new RemoteRunListener(remote));
     new RemoteTestRunner(this, remote, Class.forName(className)).run(notifier);
   } catch (Throwable failure) {
     runner = failure;
     throw failure;
   }
 }
 @Override
 public void run(RunNotifier notifier) {
   RunListener failureSpy = new ScreenshotCaptureListener();
   notifier.removeListener(failureSpy);
   notifier.addListener(failureSpy);
   try {
     super.run(notifier);
   } finally {
     notifier.removeListener(failureSpy);
   }
 }
Пример #6
0
 @Override
 public void evaluate() throws Throwable {
   Error error = error();
   notifier.addListener(listener);
   try {
     log.debug(displayName(description) + " STARTED");
     for (int retry = 1; retry <= retryCount(); retry++) {
       gotFailure = false;
       onEnter(retry);
       try {
         log.debug(displayName(description) + " retry " + retry);
         base.evaluate();
       } catch (AssumptionViolatedException cause) {
         Throwable t = new Throwable("On retry " + retry).initCause(cause);
         error.addSuppressed(t);
         notifier.fireTestAssumptionFailed(new Failure(description, t));
       } catch (Throwable cause) {
         // Repeat annotation is on method (else the Throwable is not raised up to here)
         Throwable t = new Throwable("On retry " + retry).initCause(cause);
         error.addSuppressed(t);
         if (returnOnFailure()) {
           notifier.fireTestFailure(new Failure(description, t));
         } else {
           gotFailure = true;
           log.debug(displayName(description) + " FAILURE SWALLOW");
           log.trace(t, t);
         }
       } finally {
         onLeave();
       }
       if (gotFailure && returnOnFailure()) {
         log.debug(displayName(description) + " returnOnFailure");
         return;
       }
       if (!gotFailure && returnOnSuccess()) {
         log.debug(displayName(description) + " returnOnSuccess");
         return;
       }
     }
   } finally {
     log.debug(displayName(description) + " FINISHED");
     notifier.removeListener(listener);
   }
   log.trace("throw " + error);
   throw error;
 }
  @Override
  public void run(RunNotifier notifier) {
    RunListener listener =
        new RunListener() {
          WarningsCollector warningsCollector;

          @Override
          public void testStarted(Description description) throws Exception {
            warningsCollector = new WarningsCollector();
          }

          @Override
          public void testFailure(Failure failure) throws Exception {
            logger.log(warningsCollector.getWarnings());
          }
        };

    notifier.addListener(listener);

    runner.run(notifier);
  }
Пример #8
0
  @Override
  public void run(RunNotifier notifier) {
    System.setProperty("initialActivtiy", "");
    File versionFile = new File(System.getProperty("user.dir"), "version.info");
    Versioning versioning = new Versioning(versionFile, LauncherRunner.class);
    versioning.upgradeToCurrentVersion();

    Launcher launcher = Launcher.instance;
    if (!launcher.isStarted()) {
      launcher.startAll();
      launcher.awaitStart();
    }
    notifier.addListener(
        new RunListener() {
          @Override
          public void testStarted(Description description) throws Exception {
            super.testStarted(description);
            log.info("@Test:{}.{}", description.getClassName(), description.getMethodName());
          }
        });
    super.run(notifier);
  }
  @Override
  public List<TestClassResult> runTest(
      final ServiceReference<Object> reference, final boolean developmentMode) {
    LOGGER.info("Test OSGI Service will be run by JUnit: " + reference.toString());
    List<TestClassResult> result = new ArrayList<TestClassResult>();
    try {
      Object service = bundleContext.getService(reference);
      String[] klassNames = (String[]) reference.getProperty(Constants.OBJECTCLASS);
      if (klassNames == null) {
        LOGGER.severe("Cannot load interface names for Junit service");
        return Collections.emptyList();
      }
      Filter developmentModeFilter = null;
      if (developmentMode) {
        developmentModeFilter = new DevelopmentModeFilter();
      }
      for (String klassName : klassNames) {

        try {
          Class<?> klass = reference.getBundle().loadClass(klassName);

          if (service == null) {
            long now = new Date().getTime();
            List<TestCaseResult> testCases =
                createErrorTestCaseResults(klass, developmentMode, now);
            result.add(
                new TestClassResult(
                    klass.getName(), 0, testCases.size(), 0, 0, now, now, testCases));
          } else {
            try {
              BlockJUnit4ObjectRunner runner = new BlockJUnit4ObjectRunner(klass, service);
              if (developmentModeFilter != null) {
                try {
                  runner.filter(developmentModeFilter);
                } catch (NoTestsRemainException e) {
                  LOGGER.warning(
                      "Skipping all methods from class "
                          + klass
                          + " due to development mode. To run the tests in development mode, annotate or "
                          + "methods or the class with @TestDuringDevelopment");
                }
              }

              RunNotifier notifier = new RunNotifier();
              ExtendedResultListener extendedResultListener = new ExtendedResultListener();
              notifier.addListener(extendedResultListener);
              runner.run(notifier);
              ExtendedResult extendedResult = extendedResultListener.getResult();
              extendedResult.finishRunning();

              List<TestCaseResult> testCaseResults = new ArrayList<TestCaseResult>();

              for (FlowTestCaseResult flowTestCaseResult : extendedResult.getTestCaseResults()) {
                TestCaseResult testCaseResult =
                    new TestCaseResult(
                        flowTestCaseResult.getMethodName(),
                        flowTestCaseResult.getStartTime(),
                        flowTestCaseResult.getFinishTime(),
                        flowTestCaseResult.getFailure());
                testCaseResults.add(testCaseResult);
              }

              long runCount = extendedResult.getRunCount() + extendedResult.getIgnoreCount();
              result.add(
                  new TestClassResult(
                      klassName,
                      runCount,
                      extendedResult.getErrorCount(),
                      extendedResult.getFailureCount(),
                      extendedResult.getIgnoreCount(),
                      extendedResult.getStartTime(),
                      extendedResult.getFinishTime(),
                      testCaseResults));
            } catch (InitializationError e) {
              handleInitializationError(developmentMode, result, klassName, klass, e);
            }
          }
        } catch (ClassNotFoundException e) {
          Object testIdObject = reference.getProperty(TestRunnerConstants.SERVICE_PROPERTY_TEST_ID);
          LOGGER.log(Level.SEVERE, "Could not load the class of the test: " + testIdObject, e);
        }
      }
    } finally {
      bundleContext.ungetService(reference);
    }

    return result;
  }
Пример #10
0
 public void run(final RunNotifier notifier) {
   notifier.addListener(seleniumRunListener);
   super.run(notifier);
 }
Пример #11
0
 /*
  * (non-Javadoc)
  *
  * @see org.junit.runners.ParentRunner#run(org.junit.runner.notification.RunNotifier)
  */
 @Override
 public void run(RunNotifier notifier) {
   notifier.addListener(new FrameworkUsageValidator(notifier));
   super.run(notifier);
 }
Пример #12
0
 /**
  * Add a listener to be notified as the tests run.
  *
  * @param listener the listener to add
  * @see org.junit.runner.notification.RunListener
  */
 public void addListener(RunListener listener) {
   fNotifier.addListener(listener);
 }
 @Override
 public void run(RunNotifier notifier) {
   notifier.addListener(new GwtRunListener());
   GwtConfig.get().setupGwtModule(getTestClass().getJavaClass());
   super.run(notifier);
 }