easymock - java.lang.AssertionError: Unexpected method call convertMessagesAsAppropriate(com.Response@1bb35b) -
Need help deciding whether the approach
to test the piece below the code I have Should be kept for the method called
private messageAOF messageADO; Public Response Verification User (Request Request) {Feedback Response = Zero; If (some condition) {/ * ----------- some resources are here ---------- * /} Other {feedback = build Response (errorCode, errorDesc); } // More feedback with message response response = messageDAOInf .convertmessagesAsApprotriate (feedback); Return feedback; } My EasyMock code is here
/ ** Message Dao INF * / private messageAdof messageAdof; Private VerifyUserService verifyUserServiceI; @ First public set-up () throws an exception {messageDAOInf = EasyMock.createMock (MessageDAOInf.class); VerifyUserService = new VerifyUserService (); VerifyUserService.setMessageDAOInf (messageDAOInf); } @Test Public Zero TesterRRPS (Request Request = loadRequest (); Feedback reaction = creation errors (); EasyMock.expect (messageDAOInf.convertMessagesAsApprotriate (Answer)). And return (feedback); EasyMock.replay (messageDAOInf); Answer Response 2 = Verify User Service Server (request); AssertFailedResponse (response2); } The issue is from the line
response = constructResponse (errorCode, errorDesc); This creates response error verifyUser method messageDAOInf.convertMessagesAsAppropriate () passes the
But with some simple imitation another example passes (made a joke) and>
java.lang.AssertionError: unexpected method calls convertMessagesAsAppropriate (*** Response @ 1bb35b ***): convertMessagesAsAppropriate (*** Response @ 1b5d2b2 ***): expected: 1, the actual on org.easymock.internal.ObjectMethodsFilter.invoke (ObjectMethodsFilter.java:56) at 0 org.easymock.internal.MockInvocationHandler.invoke (MockInvocationHandler.java:29)
Let me Know what I want to approach, thanks.
hope your initialization code that modifications that you have made as basically an underlying convertMessagesAsAppropriate will be called with The exact example of the response that you created in the test: obviously it will not do this. EasyMock.anyObject () that using the method response will allow the example. If you want to see your unit in the test, then it is okay. Alternatively your ArgumentMatcher Additional arguments can add this error to actually prove that is passed as an argument Rispons or Capture response and it Check in your test, depending on your testing level: -)
Comments
Post a Comment