NoClassDefFoundError when using Powermock

I just solved this one now, when I added the @RunWith(PowerMockRunner.class) attribute, eclipse automatically imported:

import org.powermock.modules.junit4.legacy.PowerMockRunner;

All I needed to do is change it to be:

import org.powermock.modules.junit4.PowerMockRunner;

And now it works fine with JUnit 4.8.2.

The 2nd runner is for when running with older versions of JUnit – specifically 4.3 and older.

Leave a Comment