Issue
I am trying to write Android Instrumented test using Espresso. When I run the test I get this error
java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
I can't understand what this error means.
I will briefly explain what I am doing in my test. I followed the samples given by google and EspressoTesting Tutorial
@SmallTest
@RunWith(AndroidJUnit4.class)
public class ActivityInputTest {
@Rule
public ActivityTestRule<ActivityInput> aiRule = new ActivityTestRule<>(ActivityInput.class);
@Before
public void setUp(){}
}
When I run the test the error occurs at annotation @Rule
. Can I get some explanation why this happens or what is the issue behind this? I am not interested in working code but more on the actual problem behind the issue.
Solution
I also experienced error exactly same with you, because I used androidx
library. I suggest you to check your libraries in build.gradle and change your dependencies for UI test like these block codes:
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "com.android.support.test:rules:1.0.2"
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Choose one of them, using com.android.support.test
, or androidx
library, because if we use them together, they will conflict each other. Hope this can help you to resolve error No instrumentation registered! Must run under a registering instrumentation.
Answered By - audrians
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.