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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -