Did you annotate the test class with @RunWith(PowerMockRunner.class)
and @PrepareForTest(CommandLineOptionProcessor.class)
?
@RunWith(PowerMockRunner.class)
@PrepareForTest(CommandLineOptionProcessor.class)
public class TestClass {
@Test
public void testRun(){
You need the @PrepareForTest(CommandLineOptionProcessor.class)
at the test class level. See the Powermock doc:
Use the @PrepareForTest(ClassThatContainsStaticMethod.class) annotation at the class-level of the test case.
Also ensure that the required libraries are on the test classpath.
In your case the javassist library is missing. Put it on the classpath. Maybe some other libs are also missing... we will see.
If you get
java.lang.IllegalArgumentException: Not a mock: java.lang.Class
then you are using EasyMock.replay()
, but you must use PowerMock.replay()