Reputation: 19421
why are thread names different when I start a Robolectric test from Android Studio vs. the Gradle build?
e.g. consider this simple test:
@RunWith(RobolectricTestRunner.class)
public class RobolectricRxThreadTest {
@Test
public void testMainThreadName() {
assertEquals("main", Thread.currentThread().getName());
}
}
when I start this test
:app
- Tasks
- verification
- test
, or from the Terminal view: ./gradlew test
) it fails.Thread worker
and not main
as expected.Upvotes: 1
Views: 277
Reputation: 20140
I just reproduced the issue, but I wonder why do you need this test?
If you really want to check main thread then the correct way would be:
assertThat(Thread.currentThread()).isEqualTo(Looper.getMainLooper().getThread());
And this test pass from AS and console both runs.
Upvotes: 1