Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-2079

exception with long message removes test from result instead of failing it

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.0.0-M6
    • 3.0.0-M7
    • Maven Surefire Plugin

    Description

      surefire 3.0.0-M6 excludes a test from the test result, if an exception with a long message (~1000) is thrown from an inner class.

          $ mvn test
          [...]
          [INFO] Running org.example.ThrowExceptionWithLongMessageTest
          [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 s - in org.example.ThrowExceptionWithLongMessageTest
          [INFO]
          [INFO] Results:
          [INFO]
          [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
          [INFO]
          [WARNING] Corrupted channel by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file     [INFO]     [...]
          [...]
          [INFO] BUILD SUCCESS
      

      with

      test class
      package org.example;
      
      import org.junit.jupiter.api.Test;
      
      class ThrowExceptionWithLongMessageTest {
      
          @Test
          public void example() {
              Inner.throwException(1000);
          }
              
          public static class Inner {
              public static void throwException(final int messageLen) {
                  final var sb = new StringBuilder();
                  for (int i = 0; i < messageLen; i++) {
                      sb.append("A");
                  }
                  throw new IllegalStateException(sb.toString());
              }
          }
      }
      

      Demonstrator: see links

      surefire 3.0.0-M5 fails the test like expected:

          [INFO] Running org.example.ThrowExceptionWithLongMessageTest
          [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.036 s <<< FAILURE! - in org.example.ThrowExceptionWithLongMessageTest
      

      Attachments

        1. SUREFIRE-2079.txt
          11 kB
          Zoltan Meze

        Issue Links

          Activity

            People

              sjaranowski Slawomir Jaranowski
              mickroll Michael Kroll
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: