UiThreadTest
Artifact: androidx.test:rules
@Target(value = [ElementType.METHOD, ElementType.TYPE])
@Retention(value = RetentionPolicy.RUNTIME)
public annotation UiThreadTest
Classes and methods annotated with this annotation will be executed on the application's UI thread (or main thread).
This annotation will only take effect for org.junit.Test
, org.junit.Before
or org.junit.After
methods.
Use runOnMainSync
if you need to switch in and out of the UI thread within your method.