8

At my job my actual responsibility is to test and refactor the old code.

I read 2 books about testing and testing with legacy code and now I'm stuck at a point and there is no progress.

I just want to mock an object with PowerMock because of an static initializer. But now my problem is, as soon as I add the "RunWith" annotation my test is crashing.

Here is my stack trace.

java.lang.IllegalStateException: Failed to transform class with name test.ContentPanelTest. Reason: java.io.IOException: invalid constant type: 18
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:266)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:145)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:40)

I thought it could be a problem with my JRE. So I've updated every library I'm using to the latest version. But the problem is still the same.

I've tried several suggested solutions from the internet. But not at least one helped me with my problem.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
R. Kuehteubl
  • 101
  • 1
  • 9

0 Answers0