Note that there are some explanatory texts on larger screens.

plurals
  1. POPowermock (With Easymock) no last call on a mock available
    text
    copied!<p>I am trying to just run a simple test case. I have the following method.</p> <pre><code>public static void run(String[] args) throws Throwable { CommandLineArguments opts = CommandLineOptionProcessor.getOpts(args); } </code></pre> <p>I will continue to build this method / test case as I go. However I just wanted to make sure a simple test case worked first. So I wrote the following test.</p> <pre><code>@Test public void testRun() { String[] args = {"--arg1", "value", "--arg2", "value2"}; mockStatic(CommandLineOptionProcessor.class); expect(CommandLineOptionProcessor.getOpts(args)); EasyMock.replay(CommandLineOptionProcessor.class); } </code></pre> <p>After that I get the following error:</p> <pre><code>java.lang.IllegalStateException: no last call on a mock available </code></pre> <p>I read some of the other posts on StackOverflow but their solution seemed to be that they were using PowerMock with Mockito. I am using Powermock and Easymock, so that should not be the problem.</p> <p>I followed Rene's advice and added the following to the top of my class.</p> <pre><code>@PrepareForTest(CommandLineOptionProcessor.class) @RunWith(PowerMockRunner.class) public class DataAssemblerTest { </code></pre> <p>I fixed the previous error. But now I have this error.</p> <pre><code>java.lang.IllegalArgumentException: Not a mock: java.lang.Class at org.easymock.internal.ClassExtensionHelper.getControl(ClassExtensionHelper.java:61) at org.easymock.EasyMock.getControl(EasyMock.java:2172) at org.easymock.EasyMock.replay(EasyMock.java:2074) . . . </code></pre> <p>Any ideas on what could be causing this would be great.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload