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

surefire-junit47 does not work in an OSGi classloader environment

    XMLWordPrintableJSON

    Details

      Description

      while trying to port JUnitCoreProvider to tycho, I noticed that it fails with an NPE when run inside an OSGi environment.

      The root cause is really JUnit bug
      https://github.com/KentBeck/junit/issues/364

      JUnit uses Class.forName() to load the test class which assumes the JUnit classloader can always load test classes, which is not true in an OSGi classloader environment.

      While this should be fixed in JUnit, it's easy to work around this issue in surefire.

      It's not necessary to use the offending org.junit.runner.Description.getTestClass() in JUnitCoreRunListener.fillTestCountMap(). We can use String getClassName() instead to circumvent classloading issues as we only need the class name anyway.

      I will attach a patch.

        Attachments

          Activity

            People

            • Assignee:
              olamy Olivier Lamy
              Reporter:
              jan.sievers Jan Sievers
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: