我正在尝试在InstrumentationTestCase中的UI线程上运行非常简单的代码,但它从未调用过。例如,此测试通过。我怎样才能正确运行?
public class Test1 extends InstrumentationTestCase {
@Test
public void testUI() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);
runTestOnUiThread(new Runnable() {
@Override
public void run() {
fail();
}
});
try {
signal.await(30, TimeUnit.SECONDS); // wait for callback
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}