1

Why does this code:

public class SomeTest extends InstrumentationTestCase {
    @UiThreadTest
    public void testSubscribe_noErrorHandler_threadingCorrect() throws Throwable {
        android.util.Log.i("Now@" + Thread.currentThread().currentThread().getId());
        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
               android.util.Log.i("Later@" + Thread.currentThread().currentThread().getId());
            }
        });
    }
}

..produce this output:

09-11 15:20:10.783    5155-5170/com.agens.android.vgsnarvei I/﹕ Now@2018
09-11 15:20:10.783    5155-5155/com.agens.android.vgsnarvei I/﹕ Later@1

I expected Now@1, Later@1, given that the documentation of @UiThreadTest claims it's supposes to run on the UI thread

Nilzor
  • 18,082
  • 22
  • 100
  • 167

1 Answers1

0

See this UiThreadTestRule

post answer about this question : https://stackoverflow.com/a/35803978/3213789

Community
  • 1
  • 1
godbye
  • 154
  • 1
  • 4