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

Surefire tries to instantiate nested TestCase classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0 (2.2 plugin)
    • None
    • None
    • Windows XP, Java 1.4.2

    Description

      If a JUnit TestCase contains any kind of nested class (static or not), Surefire feels obliged to try and instantiate it. This will fail with access violations if the class is not public.

      Work around seems to be to make the nested class public, but surely Surefire has no business doing this anyway?

      Here is a sample stack trace:

      org.apache.maven.surefire.booter.SurefireExecutionException: Unable to instantiate POJO 'class au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent'; nested exception is java.lang.InstantiationException: au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent; nested exception is org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate POJO 'class au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent'; nested exception is java.lang.InstantiationException: au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent
      org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate POJO 'class au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent'; nested exception is java.lang.InstantiationException: au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent
      java.lang.InstantiationException: au.com.optus.eFulfilment.sap.test.moduleTest.TestSapOrderComponent$MySapOrderComponent
      at java.lang.Class.newInstance0(Class.java:293)
      at java.lang.Class.newInstance(Class.java:261)
      at org.apache.maven.surefire.testset.PojoTestSet.<init>(PojoTestSet.java:52)
      at org.apache.maven.surefire.junit.JUnitDirectoryTestSuite.createTestSet(JUnitDirectoryTestSuite.java:61)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:93)
      at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:147)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:108)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sfcoy Stephen Coy
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: