Matt Matt - 4 months ago 61
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.


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.