Matt Matt - 1 year ago 199
Java Question

PowerMock NoClassDefFoundError

I have some simple classes I'm using to see if I can get

to work:

import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

public class FooTest
public void testFoobar(){
Foo test = PowerMock.createPartialMock(Foo.class, "foobar");


public class Foo
public String foobar(String aString){
return aString + " blah";

When I try to run this unit test, it tells me:

java.lang.NoClassDefFoundError: org/easymock/classextension/internal/ClassProxyFactory$MockMethodInterceptor

I have no idea why its doing this. Please help.

Answer Source

Make sure you're including EasyMock in your class path when using PowerMock... you can find the download page here.

According to the Wiki on PowerMock, it states that EasyMock is a dependency.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download