• Register
0 votes
621 views

Problem :

I am getting bellow error while executing JUNIT code
java.lang.illegalstateexception no last call on a mock available
6 5 3
6,930 points

1 Answer

0 votes

Solution :

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.

9 7 4
38,600 points

Related questions

0 votes
2 answers 3.1K views
3.1K views
Problem : When I try to run my Maven Spring project as JUnit i get bellow error java.lang.illegalstateexception: failed to load applicationcontext
asked Nov 2, 2019 peterlaw 6.9k points
0 votes
1 answer 1.1K views
1.1K views
Problem : I am trying to pass the values from the servlet to jsp page But when I run the page I am facing below error: Error as below : java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed org.apache.catalina.connector. ... getRequestDispatcher("usertaskpage.jsp"); dd.forward(request, response); But still I got a same error. How can I fix above error?
asked Feb 3 jwilliam 3.9k points
0 votes
1 answer 59 views
59 views
Problem : I am trying to run Java Applet and getting bellow error. java.lang.illegalstateexception: failed to create a child event loop
asked Oct 31, 2019 peterlaw 6.9k points
0 votes
0 answers 18 views
18 views
i got this error and was unable to solve it. Please help me with this.  //// Exception in thread "main" java.util.NoSuchElementException       at java.util.Scanner.throwFor(Scanner.java:862)       at java.util.Scanner.next( ...                     }                 }             }             System.out.println("The first distribution for students among the available sections");           }
asked Oct 2 sara s 120 points
0 votes
1 answer 34 views
34 views
Problem : Now a days I am learning Android Programming. I am facing below error message while trying to implement the logout functionality for the Google Sign-In for the Android: “Caused by: java.lang.IllegalStateException: GoogleApiClient is not ... .getInstance().getClient(); Auth.GoogleSignInApi.signOut(myGoogleApiClient); } I am struggling to find solution on it since yesterday.
asked Feb 27 mphil 2.3k points