If you want to extract, assemble or emphasize the returned or recalled argument.
This will draw arguments from the first and second logic and return ticket objects.
when (mockTicketMaker.getTicket (any (double class), any (string. Class)). Then. Answers (new answer: gt; {personal} Int Ticket No. 1; Override Public Ticket Answer (Invocation Oncok Innovation) throws throttle (double price = (double) invocation. GateArgagram () [0]; string destination = (string) invocation.getArguments () [1]; AssertEquals (new double (123.56), price); new ticket ();}});
It seems that you passed a method Instead of emphasizing the inline answer and the emphasis on the answer, a more spectacular solution is provided by the Mokito.
Given
< Code> Public category tickets {public zero getTicket (double arg1, string arg2) {}}
You can write the following in a test
@ Test Public Zero CaptureAgreement () {TicketMaker mockTicketMaker = Mockito.mock (TicketMaker.class); Fake Ticket by .getTicket (23.0d, "Some" ); ArgumentCaptor & LT; Double & gt; DoubleCaptor = Logic Copter. ForClass (double class); ArgumentCaptor & LT; String & gt; StringCaptor = Logic Copter. Forbes (string class); Mockito.verify (mockTicketMaker) .getTicket (doublecaptorcapture), stringcaptordapture ()); AssertThat (doubleCaptor.getValue ()) isEqualTo (23.0d). AssertThat (stringCaptor.getValue ()) isEqualTo ("something") .; }
No comments:
Post a Comment