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

JUnit47 provider: Exception in JUnit Runner can crash test run without visible stack trace

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.17
    • None
    • None
    • Patch

    Description

      Run the attached Maven project. Surefire is configured to use the JUnit47 provider. There's one test, marked with @RunWith(BadRunner.class); the BadRunner class throws a NullPointerException in its "run" method.

      Expected: The tests should fail with a visible stacktrace; that's what happens when you don't use the JUnit47 provider.

      Actual: The tests fail with this unhelpful error:

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project test: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test failed: java.lang.RuntimeException: null,null,null,null,null: source is null -> [Help 1]
      

      I'm also attaching a patch that fixes this problem: SimpleReportEntry should not throw a NPE with a null source/name, but should instead just accept them and convert them to the string "null." This allows the test to fail naturally and render the stacktrace in the console output and in surefire reports.

      Attachments

        1. SUREFIRE-1041-testcase.zip
          2 kB
          Daniel Fabulich
        2. SUREFIRE-1041.patch
          0.8 kB
          Daniel Fabulich

        Activity

          People

            agudian Andreas Gudian
            dfabulich Daniel Fabulich
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: