Java Code Examples for org.junit.runner.notification.Failure#getDescription()

The following examples show how to use org.junit.runner.notification.Failure#getDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CdiTestSuiteRunner.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Override
public void testFailure(Failure failure) throws Exception
{
    Level level = this.logger.getLevel();

    this.logger.setLevel(Level.INFO);

    if (TRUE.equals(IS_CDI_TEST_RUNNER_EXECUTION.get()))
    {
        Description description = failure.getDescription();
        this.logger.info("[failed] " + description.getClassName() + "#" + description.getMethodName() +
            " message: " + failure.getMessage());
    }

    try
    {
        super.testFailure(failure);
    }
    finally
    {
        this.logger.setLevel(level);
    }
}
 
Example 2
Source File: TestRunner.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Remember that a test failed, and prints output if it was not already done
 */
@Override
public void testFailure(final Failure failure) {
    final Description description = failure.getDescription();
    final String methodName = description.getMethodName();
    addDependencyFailure(methodName);
    final long seed = TestCase.randomSeed;
    if (seed != 0) {
        final String className = description.getClassName();
        final PrintWriter out = TestCase.out;
        out.print("Random number generator for ");
        out.print(className.substring(className.lastIndexOf('.') + 1));
        out.print('.');
        out.print(methodName);
        out.print("() was created with seed ");
        out.print(seed);
        out.println('.');
        // Seed we be cleared by testFinished(…).
    }
    if (!TestCase.VERBOSE) {
        TestCase.flushOutput();
    }
    // In verbose mode, the flush will be done by testFinished(…).
}
 
Example 3
Source File: ExecutionResults.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** 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);
}
 
Example 4
Source File: TeamCityListener.java    From dekaf with Apache License 2.0 5 votes vote down vote up
@Override
public void testFailure(Failure f) throws Exception {
  Description d = f.getDescription();
  say("##teamcity[testFailed name='%s' message='%s' details='%s']",
      getTestName(d),
      f.getMessage(),
      f.getTrace());
}
 
Example 5
Source File: IltConsumerJUnitListener.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Override
public void testFailure(Failure failure) {
    logger.info(">>> testFailure called");

    Description description = failure.getDescription();
    printDescription(description, 1);
    logger.info("- failure.getException() = " + failure.getException());
    logger.info("- failure.getMessage() = " + failure.getMessage());
    logger.info("- failure.getTestHeader() = " + failure.getTestHeader());
    logger.info("- failure.getTrace() = " + failure.getTrace());

    if (description == null || description.getDisplayName() == null) {
        logger.info("<<< testFinished called");
        return;
    }

    // should have been created already in previous call to testStarted
    TestSuiteResultsStore store = getStore(description);

    TestCaseFailure testCaseFailure = new TestCaseFailure(failure.getMessage(), // message
                                                          failure.getException().toString(), // type
                                                          failure.getTrace() // text
    );
    TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description),
                                                       getTestSuiteClassName(description),
                                                       null, // test not finished yet, will be updated later
                                                       "failed", // status
                                                       testCaseFailure, // failure
                                                       null // no systemOut
    );
    store.testCaseResults.add(testCaseResult);
    store.failures++;
    // everything else will be done in testFinished, which is also
    // called for failed tests as well.

    logger.info("<<< testFailure called");
}
 
Example 6
Source File: IltConsumerJUnitListener.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Override
public void testAssumptionFailure(Failure failure) {
    logger.info(">>> testAssumptionFailure called");
    Description description = failure.getDescription();
    printDescription(description, 1);
    // should have been created already in previous call to testStarted
    TestSuiteResultsStore store = getStore(description);
    store.errors++;
    logger.info("<<< testAssumptionFailure called");
}
 
Example 7
Source File: IltConsumerJUnitListener.java    From joynr with Apache License 2.0 5 votes vote down vote up
public void testFailure(Failure failure) {
    String fullTestClassName;
    String baseTestClassName;

    logger.info(">>> testFailure called");

    Description description = failure.getDescription();
    printDescription(description, 1);
    logger.info("- failure.getException() = " + failure.getException());
    logger.info("- failure.getMessage() = " + failure.getMessage());
    logger.info("- failure.getTestHeader() = " + failure.getTestHeader());
    logger.info("- failure.getTrace() = " + failure.getTrace());

    if (description == null || description.getDisplayName() == null) {
        logger.info("<<< testFinished called");
        return;
    }

    // should have been created already in previous call to testStarted
    TestSuiteResultsStore store = getStore(description);

    TestCaseFailure testCaseFailure = new TestCaseFailure(failure.getMessage(), // message
                                                          failure.getException().toString(), // type
                                                          failure.getTrace() // text
    );
    TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description),
                                                       getTestSuiteClassName(description),
                                                       null, // test not finished yet, will be updated later
                                                       "failed", // status
                                                       testCaseFailure, // failure
                                                       null // no systemOut
    );
    store.testCaseResults.add(testCaseResult);
    store.failures++;
    // everything else will be done in testFinished, which is also
    // called for failed tests as well.

    logger.info("<<< testFailure called");
}
 
Example 8
Source File: IltConsumerJUnitListener.java    From joynr with Apache License 2.0 5 votes vote down vote up
public void testAssumptionFailure(Failure failure) {
    logger.info(">>> testAssumptionFailure called");
    Description description = failure.getDescription();
    printDescription(description, 1);
    // should have been created already in previous call to testStarted
    TestSuiteResultsStore store = getStore(description);
    store.errors++;
    logger.info("<<< testAssumptionFailure called");
}
 
Example 9
Source File: JUnitRunner.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * It's possible to encounter a Failure/Skip before we've started any tests (and therefore
 * before testStarted() has been called). The known example is a @BeforeClass that throws an
 * exception, but there may be others.
 *
 * <p>Recording these unexpected failures helps us propagate failures back up to the "buck test"
 * process.
 */
private void recordUnpairedResult(Failure failure, ResultType resultType) {
  long runtime = System.currentTimeMillis() - startTime;
  Description description = failure.getDescription();
  results.add(
      new TestResult(
          description.getClassName(),
          description.getMethodName(),
          runtime,
          resultType,
          failure.getException(),
          null,
          null));
}
 
Example 10
Source File: IsFailure.java    From spectrum with MIT License 5 votes vote down vote up
private String getMethodName(final Failure failure) {
  final String actualMethodName;
  if (failure.getDescription() == null) {
    actualMethodName = null;
  } else {
    actualMethodName = failure.getDescription().getMethodName();
  }

  return actualMethodName;
}
 
Example 11
Source File: NexusPaxExamTestIndexRule.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private void doCaptureLogsOnFailure(final Failure failure) {
  Description description = failure.getDescription();
  File lastInstallDir = lastInstallDirectory();

  // point index to the last known install of NXRM
  setDirectory(lastInstallDir);

  // need to go through all these steps to record and persist the failure and logs
  starting(description);
  failed(failure.getException(), description);
  File logDir = new File(lastInstallDir, "nexus3/log");
  captureLogs(this, logDir, description.getClassName());
  finished(description);
}
 
Example 12
Source File: ResultHolder.java    From JPPF with Apache License 2.0 5 votes vote down vote up
/**
 * Add a test failure.
 * @param failure the failure to add.
 */
public void addFailure(final Failure failure) {
  final Description d = failure.getDescription();
  //CollectionUtils.putInListMap(d.getClassName(), failure, failureMap);
  failureMap.putValue(d.getClassName(), failure);
  processDescription(d);
  failureCount++;
}
 
Example 13
Source File: DynamothCollectorFacade.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void testFailure(Failure failure) throws Exception {
	Description description = failure.getDescription();
	String key = description.getClassName() + "#" + description.getMethodName();
	failedTests.put(key, AngelicExecution.previousValue);
}
 
Example 14
Source File: TestCasesListener.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void testFailure(Failure failure) throws Exception {
    Description description = failure.getDescription();
    addTestCaseTo(failedTests(), description);
}
 
Example 15
Source File: TestEventsLogger.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void testFailure(Failure f) throws Exception {
    Description d = f.getDescription();
    createPageSrcFile(d);
    log(d).error(getMessage(d, "FAILED"));
}
 
Example 16
Source File: ParcelableFailure.java    From android-test with Apache License 2.0 4 votes vote down vote up
public ParcelableFailure(Failure failure) {
  this.description = new ParcelableDescription(failure.getDescription());
  this.trace = failure.getTrace();
}
 
Example 17
Source File: TestCasesListener.java    From nopol with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void testFailure(Failure failure) throws Exception {
    Description description = failure.getDescription();
    addTestCaseTo(failedTests(), description);
}
 
Example 18
Source File: DynamothSynthesizer.java    From nopol with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void testFailure(Failure failure) throws Exception {
    Description description = failure.getDescription();
    String key = description.getClassName() + "#" + description.getMethodName();
    failedTests.put(key, AngelicExecution.previousValue);
}
 
Example 19
Source File: ITJUnitUtils.java    From servicecomb-java-chassis with Apache License 2.0 4 votes vote down vote up
@Override
public void testFailure(Failure failure) {
  SCBFailure scbFailure = new SCBFailure(failure.getDescription(), failure.getException());
  failures.add(scbFailure);
  System.out.println(scbFailure.toString());
}