Getting started with JMock.. sanity check. (Also, this might be a repeat. I tried to post through the gmane archive, but that didn't appear to work).
I am testing a PresenterFirst pattern.. and want to test with JMock. The Presenter calls the View's addListener method which calls the Presenters run() method, which in turn calls the view creditCardAuthenticated method. I don't care about the listener being called, only that the creditCardAuthenticated method is eventually called. Given all that, is this the right way to construct the test?
final IView viewMock = context.mock(IView.class);
context.checking(new Expectations() {{
ignoring (any(IView.class)).method("addListener") ;
}}) ;
context.checking( new Expectations()
{{
oneOf (viewMock).creditCardAuthenticated(true);
}});
CreditCardPresenter presenter = new CreditCardPresenter(viewMock) ;
Greg Akins
Director of Software Development
724.935.8281 x 210 (office)
724.935.8283 (fax)
724.454.7790 (cell)