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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -