And of course you can just define your Async interface methods by
Request myAsyncMethod(AsyncCallbackString callback);
instead of
void myAsyncMethod(AsyncCallbackString callback);
then you can use normal Mockito-syntax, ala
when(service.myAsyncMethod(any(AsyncCallback.class))).thenAnswer(new
I always though this produced nicely readable tests for async calls:
http://blog.reflectedcircle.co.uk/2009/12/08/gwt-rpc-asynccallback-testing-using-mockito/
Greetz
On Aug 12, 11:24 am, Magno Machado magn...@gmail.com wrote:
Code from a @Test method:
ListPesquisaProxy pesquisas = new
Code from a @Test method:
ListPesquisaProxy pesquisas = new ArrayListPesquisaProxy();
Request? request = mock(Request.class);
doReturn(request).when(pesquisaRequest).listAll();
doReturn(pesquisaRequest).when(requestFactory).pesquisaRequest();
Hi all,
I want to know how to use Mockito for testing Async calls. I went
through few blogs, and I am not sure it is implemented and how it
runs. For instance, if I have an server implementation as:
public class GreetingServiceImpl extends RemoteServiceServlet
implements GreetingService
In my experience, using of mocking frameworks for testing of Async calls is
not so good and tests are becoming un-readable at some point of time. In our
app we are using Command Pattern to send different requests
(Action/Response) and here is our helper class that we are using for
testing:
you can see gwt-dispatch http://code.google.com/p/gwt-dispatch/ for
command pattern.
2011/8/11 Miroslav Genov mge...@gmail.com
In my experience, using of mocking frameworks for testing of Async calls is
not so good and tests are becoming un-readable at some point of time. In our
app we are
Here's how I do it.
@Test
public void testAsync() {
doAnswer(new AnswerVoid() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable
{
AsyncCallbackCommandResult callback =
(AsyncCallbackCommandResult)