Java 类org.junit.runner.notification.Failure 实例源码

项目:Reer    文件:JUnitTestEventAdapter.java   
@Override
public void testFailure(Failure failure) throws Exception {
    TestDescriptorInternal testInternal;
    synchronized (lock) {
        testInternal = executing.get(failure.getDescription());
    }
    boolean needEndEvent = false;
    if (testInternal == null) {
        // This can happen when, for example, a @BeforeClass or @AfterClass method fails
        needEndEvent = true;
        testInternal = nullSafeDescriptor(idGenerator.generateId(), failure.getDescription());
        resultProcessor.started(testInternal, startEvent());
    }
    resultProcessor.failure(testInternal.getId(), failure.getException());
    if (needEndEvent) {
        resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(timeProvider.getCurrentTime()));
    }
}
项目:n4js    文件:N4IDEXpectRunListener.java   
/**
 * Called when an atomic test fails.
 *
 * @param failure
 *            describes the test that failed and the exception that was thrown
 */
@Override
public void testFailure(Failure failure) throws Exception {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {

            IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
            try {
                N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
                        N4IDEXpectView.ID);
                view.notifyFailedExecutionOf(failure);
            } catch (PartInitException e) {
                N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
            }
        }
    });
}
项目:n4js    文件:N4IDEXpectRunListener.java   
/**
 * Called when an atomic test flags that it assumes a condition that is false
 *
 * describes the test that failed and the {@link AssumptionViolatedException} that was thrown
 */
@Override
public void testAssumptionFailure(Failure failure) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {

            IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
            try {
                N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
                        N4IDEXpectView.ID);
                view.notifyFailedExecutionOf(failure);
            } catch (PartInitException e) {
                N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
            }
        }
    });
}
项目:marathonv5    文件:DisplayWindow.java   
@Override public void endTest(final PlaybackResult result) {
    if (!exploratoryTest) {
        Platform.runLater(new Runnable() {
            @Override public void run() {
                resultPane.addResult(result);
            }
        });
    }
    if (!needReports()) {
        return;
    }
    if (!exploratoryTest && result.hasFailure()) {
        MarathonAssertion assertion = new MarathonAssertion(result.failures(), getFilePath());
        runListener.testAssumptionFailure(
                new Failure(Description.createTestDescription(MarathonTestCase.class, getFilePath()), assertion));
    }
    TestAttributes.put("test_object", testCase);
    runListener.testFinished(Description.createTestDescription(MarathonTestCase.class, getFilePath()));
    addScreenCaptures();
}
项目:hadoop-oss    文件:TestTimedOutTestsListener.java   
@Test(timeout=30000)
public void testThreadDumpAndDeadlocks() throws Exception {
  new Deadlock();
  String s = null;
  while (true) {
    s = TimedOutTestsListener.buildDeadlockInfo();
    if (s != null)
      break;
    Thread.sleep(100);
  }

  Assert.assertEquals(3, countStringOccurrences(s, "BLOCKED"));

  Failure failure = new Failure(
      null, new Exception(TimedOutTestsListener.TEST_TIMED_OUT_PREFIX));
  StringWriter writer = new StringWriter();
  new TimedOutTestsListener(new PrintWriter(writer)).testFailure(failure);
  String out = writer.toString();

  Assert.assertTrue(out.contains("THREAD DUMP"));
  Assert.assertTrue(out.contains("DEADLOCKS DETECTED"));

  System.out.println(out);
}
项目:elasticsearch_my    文件:ReproduceInfoPrinter.java   
@Override
public void testFailure(Failure failure) throws Exception {
    // Ignore assumptions.
    if (failure.getException() instanceof AssumptionViolatedException) {
        return;
    }

    final StringBuilder b = new StringBuilder("REPRODUCE WITH: gradle ");
    String task = System.getProperty("tests.task");
    // TODO: enforce (intellij still runs the runner?) or use default "test" but that won't work for integ
    b.append(task);

    GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b);
    gradleMessageBuilder.appendAllOpts(failure.getDescription());

    // Client yaml suite tests are a special case as they allow for additional parameters
    if (ESClientYamlSuiteTestCase.class.isAssignableFrom(failure.getDescription().getTestClass())) {
        gradleMessageBuilder.appendClientYamlSuiteProperties();
    }

    System.err.println(b.toString());
}
项目:ats-framework    文件:AtsJunitTestListener.java   
/**
 * (non-Javadoc)
 * @see org.junit.runner.notification.RunListener#testAssumptionFailure(org.junit.runner.notification.Failure)
 */
@Override
public void testAssumptionFailure( Failure failure ) {

    if (log.isDebugEnabled()) {
        log.debug("testAssumptionFailure(): Test failed: " + failure.toString() + "| Description: "
                  + failure.getDescription());
    }
    log.info("Test assumption failure received. It will be stored in DB as test failed event.");
    try {
        testFailure(failure);
    } catch (Exception e) {
        log.error("Error while processing testFailure event", e);
    }
    super.testAssumptionFailure(failure);
}
项目:CodeU-Summer-2017    文件:TestRunner.java   
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.TokenizerTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class
      );
   for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
}
项目:xtf    文件:IntermediateReporter.java   
private boolean isKnownIssue(Failure failure) {

        if (failure == null) {
            return false;
        }

        if (failure.getDescription() == null) {
            return false;
        }

        final KnownIssue knownIssue = failure.getDescription().getAnnotation(KnownIssue.class);
        final String message = failure.getMessage();

        if (knownIssue == null || message == null || knownIssue.value() == null) {
            return false;
        }

        if (message.contains(knownIssue.value())) {
            return true;
        }

        return false;
    }
项目:ArchUnit    文件:ArchUnitIntegrationTestRunner.java   
@Override
protected void runChild(final ArchTestExecution child, final RunNotifier notifier) {
    ExpectedViolation expectedViolation = ExpectedViolation.none();
    HandlingAssertion handlingAssertion = HandlingAssertion.none();
    Description description = describeChild(child);
    notifier.fireTestStarted(description);
    try {
        ExpectedViolationDefinition violationDefinition = extractExpectedConfiguration(child);
        violationDefinition.configure(expectedViolation);
        violationDefinition.configure(handlingAssertion);
        expectedViolation.apply(new IntegrationTestStatement(child, handlingAssertion), description).evaluate();
    } catch (Throwable throwable) {
        notifier.fireTestFailure(new Failure(description, throwable));
    } finally {
        notifier.fireTestFinished(description);
    }
}
项目:bayou    文件:TestSuiteRunner.java   
/**
 * Creates and runs a JUnit test runner for testSuite.
 *
 * @param testSuite the class defining test cases to run
 * @param view a UI component to report test failures to
 * @return the counts of failures and total test cases.
 */
static RunResult runTestSuiteAgainst(Class testSuite, View view)
{
    if(testSuite == null)
        throw new NullPointerException("testSuite");

    if(view == null)
        throw new NullPointerException("view");

    Result result = new JUnitCore().run(testSuite);

    if (result.getFailureCount() > 0)
    {
        for (Failure f : result.getFailures())
            view.declarePassProgramTestFailure(f.getTrace());
    }


    return new RunResult(result.getFailureCount(), result.getRunCount());
}
项目:monarch    文件:ExpectedTimeoutRuleTest.java   
@Test
public void failsWithExpectedTimeoutButWrongError() {
  Result result = TestRunner.runTest(FailsWithExpectedTimeoutButWrongError.class);

  assertThat(result.wasSuccessful()).isFalse();

  List<Failure> failures = result.getFailures();
  assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);

  Failure failure = failures.get(0);
  String expectedMessage = "\n"
      + "Expected: (an instance of java.util.concurrent.TimeoutException and exception with message a string containing \"this is a message for FailsWithExpectedTimeoutButWrongError\")"
      + "\n" + "     "
      + "but: an instance of java.util.concurrent.TimeoutException <java.lang.NullPointerException> is a java.lang.NullPointerException";
  assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class)
      .hasMessageContaining(expectedMessage);
}
项目:hadoop    文件:TestTimedOutTestsListener.java   
@Test(timeout=500)
public void testThreadDumpAndDeadlocks() throws Exception {
  new Deadlock();
  String s = null;
  while (true) {
    s = TimedOutTestsListener.buildDeadlockInfo();
    if (s != null)
      break;
    Thread.sleep(100);
  }

  Assert.assertEquals(3, countStringOccurrences(s, "BLOCKED"));

  Failure failure = new Failure(
      null, new Exception(TimedOutTestsListener.TEST_TIMED_OUT_PREFIX));
  StringWriter writer = new StringWriter();
  new TimedOutTestsListener(new PrintWriter(writer)).testFailure(failure);
  String out = writer.toString();

  Assert.assertTrue(out.contains("THREAD DUMP"));
  Assert.assertTrue(out.contains("DEADLOCKS DETECTED"));

  System.out.println(out);
}
项目:codeu_project_2017    文件:TestRunner.java   
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class
      );
   for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
}
项目:aliyun-oss-hadoop-fs    文件:TestTimedOutTestsListener.java   
@Test(timeout=500)
public void testThreadDumpAndDeadlocks() throws Exception {
  new Deadlock();
  String s = null;
  while (true) {
    s = TimedOutTestsListener.buildDeadlockInfo();
    if (s != null)
      break;
    Thread.sleep(100);
  }

  Assert.assertEquals(3, countStringOccurrences(s, "BLOCKED"));

  Failure failure = new Failure(
      null, new Exception(TimedOutTestsListener.TEST_TIMED_OUT_PREFIX));
  StringWriter writer = new StringWriter();
  new TimedOutTestsListener(new PrintWriter(writer)).testFailure(failure);
  String out = writer.toString();

  Assert.assertTrue(out.contains("THREAD DUMP"));
  Assert.assertTrue(out.contains("DEADLOCKS DETECTED"));

  System.out.println(out);
}
项目:intellij-ce-playground    文件:JUnitTreeByDescriptionHierarchyTest.java   
private static JUnit4TestListener createListener(final StringBuffer buf) {
  return new JUnit4TestListener(new PrintStream(new OutputStream() {
    @Override
    public void write(int b) throws IOException {
      buf.append(new String(new byte[]{(byte)b}));
    }
  })) {
    @Override
    protected long currentTime() {
      return 0;
    }

    @Override
    protected String getTrace(Failure failure) {
      return StringUtil.convertLineSeparators(super.getTrace(failure));
    }
  };
}
项目:ComputerScienceGraduation    文件:Principal.java   
/**
 * Chama o motor de testes JUnit.
 */
private static void executarTodosOs50Testes()
{
   final Result result = JUnitCore.runClasses( GrafoTest.class );
   final StringBuilder mensagem = new StringBuilder();
   if( result.getFailureCount() > 0 )
   {
      mensagem.append( "############## OS SEGUINTES TESTES FALHARAM!! "
               + "#####################################\n" );
   } else
   {
      mensagem.append( "############## TODOS OS TESTES FORAM EXECUTADOS "
               + "COM SUCESSO!! #######################\n" );
   }

   for( final Failure failure: result.getFailures() )
   {
      mensagem.append( failure.getDescription() ).append( '\n' );
      mensagem.append( failure.getMessage() ).append( '\n' );
   }
   System.out.println( mensagem );
}
项目:DependencyInjector    文件:DelayedInjectionRunnerValidatorTest.java   
@Test
public void shouldValidateUnsuccessfullyForInjectMocksPresence() throws Exception {
    // given
    RunNotifier notifier = mock(RunNotifier.class);
    TestClass testClass = new TestClass(getClass());
    DelayedInjectionRunnerValidator validator = new DelayedInjectionRunnerValidator(notifier, testClass);
    Description description = mock(Description.class);

    // when
    validator.testFinished(description);

    // then
    ArgumentCaptor<Failure> captor = ArgumentCaptor.forClass(Failure.class);
    verify(notifier).fireTestFailure(captor.capture());
    Failure failure = captor.getValue();
    assertThat(failure.getMessage(), containsString("Do not use @InjectMocks"));
}
项目:Glacier    文件:GlacierTest.java   
public static void main(String[] args) {
    System.out.println("Trying to run tests");
    org.junit.runner.JUnitCore jc = new org.junit.runner.JUnitCore();
    Result run = jc.run(GlacierCheckerTests.class);

    if (run.wasSuccessful()) {
        System.out.println("Run was successful with " + run.getRunCount() + " test(s)!");
    } else {
        System.out.println("Run had " + run.getFailureCount() + " failure(s) out of "
                + run.getRunCount() + " run(s)!");

        for (Failure f : run.getFailures()) {
            System.out.println(f.toString());
        }
    }
}
项目:unitils    文件:UnitilsJUnit4TestClassRunner.java   
@Override
public void run(final RunNotifier notifier) {
    ClassRoadie classRoadie = new ClassRoadie(notifier, getTestClass(), getDescription(), new Runnable() {
        public void run() {
            runMethods(notifier);
        }
    });

    Unitils.getInstance().getTestContext().setRunner(this);
    try {
        getTestListener().beforeTestClass(getTestClass().getJavaClass());
        classRoadie.runProtected();
    } catch (Throwable t) {
        notifier.fireTestFailure(new Failure(getDescription(), t));
    }
}
项目:big-c    文件:TestTimedOutTestsListener.java   
@Test(timeout=500)
public void testThreadDumpAndDeadlocks() throws Exception {
  new Deadlock();
  String s = null;
  while (true) {
    s = TimedOutTestsListener.buildDeadlockInfo();
    if (s != null)
      break;
    Thread.sleep(100);
  }

  Assert.assertEquals(3, countStringOccurrences(s, "BLOCKED"));

  Failure failure = new Failure(
      null, new Exception(TimedOutTestsListener.TEST_TIMED_OUT_PREFIX));
  StringWriter writer = new StringWriter();
  new TimedOutTestsListener(new PrintWriter(writer)).testFailure(failure);
  String out = writer.toString();

  Assert.assertTrue(out.contains("THREAD DUMP"));
  Assert.assertTrue(out.contains("DEADLOCKS DETECTED"));

  System.out.println(out);
}
项目:aspectj-junit-runner    文件:JUnitLifeCycleTest.java   
@Test
public void run() {
    JUnitCore junitCore = new JUnitCore();
    Result result = junitCore.run(TestDummy.class);
    List<Failure>failures = result.getFailures();
    if(!(failures == null || failures.isEmpty())) {
        for(Failure f : failures) {
            System.out.println(f.getMessage());
        }
    }
    Assert.assertEquals(2, result.getRunCount());
    Assert.assertEquals(0, result.getIgnoreCount());
    Assert.assertEquals(0, result.getFailureCount());
    Assert.assertEquals("After was not executed", "true", System.getProperty("JUnit_After"));
    Assert.assertEquals("AfterClass was not executed", "true", System.getProperty("JUnit_AfterClass"));
}
项目:sam    文件:JUnitRunListener.java   
public void testRunFinished(Result result) {

      logger.info("Time: " + elapsedTimeAsString(result.getRunTime()));

      if (result.wasSuccessful()) {
        logger.info("OK (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")");
      } else {

        final List<Failure> failures = result.getFailures();
        if (failures.size() == 1) {
          logger.error("There was " + failures.size() + " failure:");
        } else {
          logger.error("There were " + failures.size() + " failures:");
        }

        for (Failure failure : failures) {
          logger.error(failure.getTestHeader());
          logger.error(failure.getTrace());
        }
        logger.info("FAILURE Tests run: " + result.getRunCount() + ",  Failures: " + result.getFailureCount());
      }
    }
项目:JEmAS    文件:EmotionAnalyzer_UI.java   
private static void runTests(){
    JUnitCore junit = new JUnitCore();
    Result result = junit.run(Tests.class);
    System.err.println("Ran " + result.getRunCount() + " tests in "+ result.getRunTime() +"ms.");
    if (result.wasSuccessful()) System.out.println("All tests were successfull!");
    else {
        System.err.println(result.getFailureCount() + "Failures:");
        for (Failure fail: result.getFailures()){
            System.err.println("Failure in: "+ fail.getTestHeader());
            System.err.println(fail.getMessage());
            System.err.println(fail.getTrace());
            System.err.println();
        }
    }

}
项目:intellij-ce-playground    文件:JUnit4TestListener.java   
private void testFailure(Failure failure, String messageName, String methodName) {
  final Map attrs = new HashMap();
  attrs.put("name", methodName);
  final long duration = currentTime() - myCurrentTestStart;
  if (duration > 0) {
    attrs.put("duration", Long.toString(duration));
  }
  try {
    final String trace = getTrace(failure);
    final Throwable ex = failure.getException();
    final ComparisonFailureData notification = createExceptionNotification(ex);
    ComparisonFailureData.registerSMAttributes(notification, trace, failure.getMessage(), attrs, ex);
  }
  catch (Throwable e) {
    final StringWriter stringWriter = new StringWriter();
    final PrintWriter writer = new PrintWriter(stringWriter);
    e.printStackTrace(writer);
    ComparisonFailureData.registerSMAttributes(null, stringWriter.toString(), e.getMessage(), attrs, e);
  }
  finally {
    myPrintStream.println("\n" + MapSerializerUtil.asString(messageName, attrs));
  }
}
项目:SilverKing    文件:SkfsRenameGlenn.java   
public static void printSummary(Result result) {
        if (!result.wasSuccessful())
            System.out.println("\n\nErrors:");

        for (Failure failure : result.getFailures()) {
//          System.out.println(failure.getMessage());
//          System.out.println(failure.getTestHeader());
//          System.out.println(failure.getDescription());
//          System.out.println(failure.getException());
            System.out.println(failure.getTestHeader());
            System.out.println(failure.getTrace());
//          System.out.println(failure.toString());
        }

        int run     = result.getRunCount();
        int failed  = result.getFailureCount();
        int ignored = result.getIgnoreCount();
        int passed  = run - failed;

        System.out.println("PASSED:  " + passed);
        System.out.println("FAILED:  " + failed);
        System.out.println("IGNORED: " + ignored);

        System.out.println("All passed?: " + String.valueOf( result.wasSuccessful() ).toUpperCase());
    }
项目:SilverKing    文件:SkfsCopyGlenn.java   
public static void printSummary(Result result) {
        if (!result.wasSuccessful())
            System.out.println("\n\nErrors:");

        for (Failure failure : result.getFailures()) {
//          System.out.println(failure.getMessage());
//          System.out.println(failure.getTestHeader());
//          System.out.println(failure.getDescription());
//          System.out.println(failure.getException());
            System.out.println(failure.getTestHeader());
            System.out.println(failure.getTrace());
//          System.out.println(failure.toString());
        }

        int run     = result.getRunCount();
        int failed  = result.getFailureCount();
        int ignored = result.getIgnoreCount();
        int passed  = run - failed;

        System.out.println("PASSED:  " + passed);
        System.out.println("FAILED:  " + failed);
        System.out.println("IGNORED: " + ignored);

        System.out.println("All passed?: " + String.valueOf( result.wasSuccessful() ).toUpperCase());
    }
项目:SilverKing    文件:Util.java   
private static void printSummary(Result result) {
        if (!result.wasSuccessful())
            println("\n\nERRORS:");

        for (Failure failure : result.getFailures()) {
//          System.out.println(failure.getMessage());
//          System.out.println(failure.getTestHeader());
//          System.out.println(failure.getDescription());
//          System.out.println(failure.getException());
            System.out.println(failure.getTestHeader());
            System.out.println(failure.getTrace());
//          System.out.println(failure.toString());
        }

        int run     = result.getRunCount();
        int failed  = result.getFailureCount();
        int ignored = result.getIgnoreCount();
        int passed  = run - failed;

        println("PASSED:  " + passed);
        println("FAILED:  " + failed);
        println("IGNORED: " + ignored);

        println("All passed?: " + String.valueOf( result.wasSuccessful() ).toUpperCase());
    }
项目:zerocode    文件:StepNotificationHandler.java   
Boolean handleAssertionFailed(RunNotifier notifier,
                Description description,
                String scenarioName,
                String stepName,
                List<AssertionReport> failureReportList) {
    /**
     * Generate error report and display clearly which expectation(s) did not match
     */
    logger.info(String.format("Failed assertion during Scenario:%s, --> Step:%s, Details: %s\n",
                    scenarioName, stepName, StringUtils.join(failureReportList, "\n")));
    notifier.fireTestFailure(new Failure(description, new RuntimeException(
                    String.format("Assertion failed for :- \n\n[%s] \n\t|\n\t|\n\t+---Step --> [%s] \n\nFailures:\n--------- %n%s%n",
                                    scenarioName,
                                    stepName,
                                    StringUtils.join(failureReportList, "\n" + deckedUpLine(maxEntryLengthOf(failureReportList)) + "\n"))
    )));

    return false;
}
项目:xtext-core    文件:AbstractParallelScenarioRunner.java   
protected Statement prepareMethodBlock(final FrameworkMethod method, final RunNotifier notifier) {
    final Statement methodBlock = superMethodBlock(method);
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            try {
                methodBlock.evaluate();
                Description description = describeChild(method);
                try {
                    notifier.fireTestStarted(description);
                    notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Method " + method.getName() + " did parse any input")));
                } finally {
                    notifier.fireTestFinished(description);
                }
            } catch(TestDataCarrier testData) {
                AbstractParallelScenarioRunner.this.testData.put(method, testData.getData());
            }
        }
    };
}
项目:junit-easy-tools    文件:ResultAssertions.java   
/**
 * Checks that result has no failures.
 * Print all the failures in error message if there are any.
 */
public static void assertResultHasNoFailures(Result result) {
    List<Failure> failures = result.getFailures();
    assertThat(failures)
            .as("No failures expected. Failures: %s",
                    failures.stream()
                            .map(ResultAssertions::formFailureDescription)
                            .collect(Collectors.toList()))
            .isEmpty();
}
项目:Reer    文件:AbstractMultiTestRunner.java   
@Override
public void run(RunNotifier notifier) {
    Description description = getDescription();
    notifier.fireTestStarted(description);
    notifier.fireTestFailure(new Failure(description, failure));
    notifier.fireTestFinished(description);
}
项目:Reer    文件:AbstractMultiTestRunner.java   
@Override
public void testStarted(Description description) {
    Description translated = translateDescription(description);
    notifier.fireTestStarted(translated);
    if (!started && !complete) {
        try {
            assertCanExecute();
            started = true;
            before();
        } catch (Throwable t) {
            notifier.fireTestFailure(new Failure(translated, t));
        }
    }
}
项目:GitHub    文件:Bug_for_Next.java   
public static void main(String[] args) throws Exception {
    Result result = JUnitCore.runClasses(Bug_for_Next.class);
    for (Failure fail : result.getFailures()) {
        System.out.println(fail.toString());
    }
    if (result.wasSuccessful()) {
        System.out.println("All tests finished successfully...");
    }
}
项目:n4js    文件:ExecutionResults.java   
/** Mark execution of given {@link Description} as failed. Parent descriptions may be updated accordingly. */
public void executionFailed(Failure failure) {
    Description description = failure.getDescription();
    allStatuses.put(description, ExecutionStatus.FAILED);
    allFailures.put(description, failure);
    updateParents(description, ExecutionStatus.FAILED);
}
项目:CodeU-ProjectGroup6    文件:TestRunner.java   
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class,
          codeu.chat.util.TokenizerTest.class,
          codeu.chat.server.ControllerTest.class
      );

   System.out.println("\n===================== Test Status ====================");
   System.out.println(String.format("%d tests run.", result.getRunCount()));

   if (result.wasSuccessful()) {
     System.out.println("All tests passed.");
   } else {
     System.out.println(String.format("%d tests failed.", result.getFailureCount()));
     System.out.println("\nFailures:");
     for (final Failure failure : result.getFailures()) {
        System.out.println(failure.toString());
     }
   }

   System.out.println("======================================================\n");
   System.exit(result.wasSuccessful() ? 0 : -1);
}
项目:marathonv5    文件:TestRunner.java   
@Override public void testAssumptionFailure(Failure failure) {
    Test t = (Test) TestAttributes.get("test_object");
    TestTreeItem testNode = findTestItem(t);
    testNode.setThrowable(new AssertionFailedError(failure.getMessage()));
    testNode.setState(State.FAILURE);
    testTree.refresh();
    Platform.runLater(() -> {
        progressBar.setError(true);
        progressBar.incrementFailures();
    });
}
项目:marathonv5    文件:TestRunner.java   
@Override public void testFailure(Failure failure) throws Exception {
    Test t = (Test) TestAttributes.get("test_object");
    TestTreeItem testNode = findTestItem(t);
    testNode.setThrowable(failure.getException());
    testNode.setState(State.ERROR);
    testTree.refresh();
    Platform.runLater(() -> {
        progressBar.setError(true);
        progressBar.incrementErrors();
    });
}
项目:marathonv5    文件:AllureMarathonRunListener.java   
@Override public void testFailure(Failure failure) {
    if (failure.getDescription().isTest()) {
        fireTestCaseFailure(failure.getException());
    } else {
        startFakeTestCase(failure.getDescription());
        fireTestCaseFailure(failure.getException());
        finishFakeTestCase();
    }
}
项目:marathonv5    文件:AllureMarathonRunListener.java   
@Override public void testFinished(Description description) {
    Test test = (Test) TestAttributes.get("test_object");
    if (test != null && test instanceof MarathonTestCase) {
        StringBuilder failed = new StringBuilder();
        List<CheckList> checklists = ((MarathonTestCase) test).getChecklists();
        for (CheckList checkList : checklists) {
            String name = checkList.getName();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            checkList.saveHTML(out);
            getLifecycle().fire(new MakeAttachmentEvent(out.toByteArray(), name, "text/html"));
            if (checkList.getCaptureFile() != null) {
                File captureFile = new File(System.getProperty(Constants.PROP_IMAGE_CAPTURE_DIR),
                        "ext-" + checkList.getCaptureFile());
                try {
                    getLifecycle().fire(new MakeAttachmentEvent(Files.readAllBytes(captureFile.toPath()),
                            name + "(ScreenCapture)", "image/png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if ("Fail".equals(checkList.getStatus())) {
                failed.append(checkList.getName()).append(", ");
            }
        }
        if (failed.length() > 0) {
            failed.setLength(failed.length() - 2);
            net.sourceforge.marathon.runtime.api.Failure[] failures = new net.sourceforge.marathon.runtime.api.Failure[] {
                    null };
            failures[0] = new net.sourceforge.marathon.runtime.api.Failure("Failed Checklists: " + failed.toString(),
                    new SourceLine[0], null);
            MarathonAssertion assertion = new MarathonAssertion(failures, ((MarathonTestCase) test).getName());
            testAssumptionFailure(new Failure(description, assertion));
        }
    }
    getLifecycle().fire(new TestCaseFinishedEvent());
}