Проблема с UI-Тестом на android
Я делаю UI-тест для своего приложения. Приложения делает следующие - пользователь вводит слова, например - Hello World, и исключения, например- Ho. И оно выдает - Hlleo dolrW. Ну то есть, инвертирует символы не исключения.
UI-Test:
package com.example.mylesson_01;
import android.support.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
public class AglorithmUiTest {
@Rule
public ActivityTestRule<MainActivity> activityActivityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void greeterSaysHello() {
onView(withId(R.id.UserInput)).perform(typeText("Hello World"));
onView(withId(R.id.enteringException)).perform(typeText("Ho"));
onView(withId(R.id.button)).perform(click());
onView(withText(R.id.stringOne)).check(matches(withText("Hlleo dolrW")));
}
}
Gradle:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.mylesson_01"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.includeAndroidResources = true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.robolectric:robolectric:4.2.1"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Когда я пытаюсь запустить тест, то выдаются вот эти ошибки -
java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
at android.support.test.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:44)
at android.support.test.InstrumentationRegistry.getTargetContext(InstrumentationRegistry.java:82)
at android.support.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:144)
at android.support.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:120)
at android.support.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:103)
at com.example.mylesson_01.AglorithmUiTest.<init>(AglorithmUiTest.java:20)
Использую эмулятор - Pixel_4a_API_30. Анимации я отключил, сижу уже 5 час не понимаю в чем проблема. Прочитал много статей, так и не нашел решения свой проблемы, буду благодарен если поможете