Let's assume that you want to cover with unit tests some asynchronous operation that you've implemented using AsyncTask. First, you need a mechanism to wait for operation to finish before test end up itself, so you can test results of this operation. The easiest way to do it is to use CountDownLatch:

public class TestCaseSomething ...{
    final CountDownLatch signal = new CountDownLatch(1);
...
    public void testSomething() {
        final AsyncOperation asyncOperation = new AsyncOperation();
        asyncOperation.setListener(this);
        asyncOperation.start();
        signal.await();
    }
...
    // Given that asyncOperation will call this onSucccess(...) at the end of the operation and pass the result
    public void onSuccess(SomeClass someResult) {
        assertNotNull(someResult);
        ...
        signal.countDown();
    }
}

In this case, signal.await() will wait for signal.countDown() to be called. Which you will call after testing the result of the operation.
So, we've done with waiting, but the above code example will not work, unless the operation will be called on the UI thread (onPostExecute() will not be called). We need to wrap asyncOperation.start() call so it will look like this:

    this.runTestOnUiThread(new Runnable() {
        public void run() {
            asyncOperation.start();
        }
    });