V
V
Valery2016-12-23 14:59:43
Android
Valery, 2016-12-23 14:59:43

Android testing. How to test a real asynchronous response?

There is a method with asynchronous response

public void doSomethingAsynchronously (final DummyCallback callback) {
    new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          Object obj = Database.get(some_arg)
          callback.onSuccess(obj);
        } catch (InterruptedException e) {
          callback.onFail(ERROR_CODE);
          e.printStackTrace();
        }
      }
    }).start();
  }

The fact is that all sorts of mocks replace the call with a fake. And I really need to check that the call took place and returned a real object.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question