junit test failures should include stack traces

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • jtreg4.2
    • Affects Version/s: None
    • Component/s: tools
    • None
    • b04

      I was puzzled by the lack of a useful stack trace containing test source files in
      https://bugs.openjdk.java.net/browse/JDK-8159767
      Looking at the jtreg sources, I see that toString is called on each junit Failure, but that is not enough to get the stacktrace. And the stacktrace is Job One!

      Here is an obvious but completely untested change (I haven't seriously tried to build recent jtreg yet)

      --- a/src/share/classes/com/sun/javatest/regtest/JUnitAction.java
      +++ b/src/share/classes/com/sun/javatest/regtest/JUnitAction.java
      @@ -119,11 +119,8 @@
                       throw new Exception(JUNIT_NO_DRIVER, ex);
                   }
                   if (!result.wasSuccessful()) {
      - List<org.junit.runner.notification.Failure> failures = result.getFailures();
      - for (Iterator<org.junit.runner.notification.Failure>
      - it = failures.iterator(); it.hasNext(); ) {
      - org.junit.runner.notification.Failure failure = it.next();
      - System.err.println("JavaTest Message: JUnit Failure: "+failure);
      + for (org.junit.runner.notification.Failure failure : result.getFailures()) {
      + System.err.println("JavaTest Message: JUnit Failure: "+failure.getTrace());
                       }
                       throw new Exception("JUnit test failure");
                   }

            Assignee:
            Jonathan Gibbons
            Reporter:
            Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: