java - EasyMock: Method with a callback argument -


i have situation this:

class {   void methoda(callback cb) {     ...     cb.onresult(result);   } }  class b {   void methodb(a a) {     a.methoda(new callback() {       void onresult(result r) {         ...       }     });   } } 

and question is: how can test "b.methodb" different "result" easymock?

you capture callback passed methoda

capture<callback> cap = new capture<callback>(); mocka.methoda(capture(cap)); replay(mocka); instanceofb.methodb(mocka); callback cb = cap.getvalue();  // can call cb.onresult mocked result instance 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -