Menu

#6 ClassCastException on instrumentation

open-postponed
nobody
5
2002-01-21
2002-01-17
No

When instrumenting junit, it throws ClassCastException
when running a test :

java.lang.ClassCastException: junit.framework.TestSuite
at
junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:53)
at
junit.awtui.TestRunner.runSuite(TestRunner.java:393)
at
junit.awtui.TestRunner$4.actionPerformed(TestRunner.java:164)
at
java.awt.TextField.processActionEvent(TextField.java:513)
at
java.awt.TextField.processEvent(TextField.java:486)
at
java.awt.Component.dispatchEventImpl(Component.java:2593)

Discussion

  • Mika Riekkinen

    Mika Riekkinen - 2002-01-18

    Logged In: YES
    user_id=350104

    Made a little further investigation on this. JUnit uses
    Class.forName(...) construct to load Tests.
    BaseTestRunner _was_ loaded with InstrumentingClassLoader.
    In getTest() method,
    Class.forName("junit.framework.TestSuite") was used, and
    this loading resulted in TestSuite being loaded by a System
    ClassLoader.

     
  • Mika Riekkinen

    Mika Riekkinen - 2002-01-21

    Logged In: YES
    user_id=350104

    Workaround :
    Exclude following classes from instrumentation :
    o junit.runner.TestCaseClassLoader
    o junit.framework.Test
    o junit.framework.AssertionFailedError

    If using test.CallTrace, commandline becomes :

    java
    -Dexclude=junit.runner.TestCaseClassLoader:junit.framework.Test:junit.framework.AssertionFailedError
    -Dinclude=junit.* test.CallTrace junit.ui.TestRunner

    This workaround will enable one to inspect calls made within
    junit. However, TestCases cannot be
    inspected.

     
  • Mika Riekkinen

    Mika Riekkinen - 2002-01-21
    • status: open --> open-works-for-me
     
  • Mika Riekkinen

    Mika Riekkinen - 2002-01-21
    • status: open-works-for-me --> open-postponed
     

Log in to post a comment.

MongoDB Logo MongoDB