Почему происходит ошибка "No instrumentation registered! Must run under a registering instrumentation"?
Я изучаю espresso для автоматизации android.
Вот мои зависимости (gradle):
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//implementation group: 'androidx.test.espresso', name: 'espresso-contrib', version: '3.5.1'
implementation group: 'com.android.support.test', name: 'runner', version: '1.0.1'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
androidTestImplementation 'info.cukes:cucumber-core:1.2.2'
androidTestImplementation 'info.cukes:cucumber-html:0.2.3'
androidTestImplementation 'info.cukes:cucumber-android:1.2.2'
testImplementation 'org.robolectric:robolectric:4.4'
androidTestImplementation 'info.cukes:cucumber-junit:1.1.8' ```
Вот мой кукумбер:
Feature: Activation
@DEV
Scenario: Activation
Given User clicks button "card_activation_code_request" in Main menu
Вот мой код:
port static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.*;
import static org.assertj.core.internal.bytebuddy.implementation.bind.annotation.IgnoreForBinding.Verifier.check;
import static org.hamcrest.CoreMatchers.anyOf;
public class CommonSteps {
@Rule
public ActivityTestRule<SplashActivity> activityTestRule = new ActivityTestRule<>(SplashActivity.class);
@Given("^User clicks button \"([^\"]*)\" in Main menu$")
public void userClicksButtonInHomeScreenMenu(String buttonName) throws Throwable {
switch (buttonName) {
case ("card_activation_code_request"):
onView(withId(R.id.ll_card_activation)).perform(click());
break;
case ("login"):
onView(withId(R.id.tv_login)).perform(click());
break;
default:
System.out.println("This" + buttonName + " button not exist");
break;
}
throw new PendingException();
}
И ругается на @Rule
public ActivityTestRule<SplashActivity> activityTestRule = new ActivityTestRule<>(SplashActivity.class);
хотя только в SplashActivity есть android.intent.category.LAUNCHER:
<activity
android:name=".splash.SplashActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Ошибка:
No instrumentation registered! Must run under a registering instrumentation.CommonSteps.<init>(CommonSteps.java:28)