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()
{
Pease note you will need the @PrepareForTest(CommandLineOptionProcessor.class) at the test class level.
Use the @PrepareForTest(ClassThatContainsStaticMethod.class) annotation at the class-level of the test case.
Also please ensure that the required libraries are on the test classpath.
In your case the javassist library is missing.
Please put it on the classpath.
If you get
java.lang.IllegalArgumentException: Not a mock: java.lang.Class
then you must be using EasyMock.replay(),
but you must use PowerMock.replay()
After following all above mentioned steps my issue got resolved.