AndroidX Espresso Test: тесты не найдены и пустой набор тестов - PullRequest
0 голосов
/ 12 января 2019

Я пытаюсь запустить src / androidTest , который является тестом инструмента в моем проекте Android, который использует библиотеки AndroidX , но я получаю No tests were found ошибку и Empty test suite журнал.

Я проверил все образцы и документы, которые используют библиотеки AndroidX, делают то же самое.

Я попытался настроить Edit Configurations по следующей ссылке https://stackoverflow.com/a/53715513/1826656 Но все равно не повезло.

Я что-то не так делаю? или пропустить какие-либо шаги?

Пожалуйста, проверьте это изображение для Журнал тестовых прогонов

MainActivityTest.java Код:

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {

   @Rule
   ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

   @Test
   public void checkViewsVisibility() {
     // verify the visibility of recycler view on screen
     onView(withId(R.id.record_list_rv)).check(matches(isDisplayed()));

     // verify the visibility of progressbar on screen
     onView(withId(R.id.progressBar)).check(matches(isDisplayed()));

     // verify the visibility of no data TextView on screen By default it should be GONE
     onView(withId(R.id.no_data_tv)).check(matches(isDisplayed()));

     onView(withId(R.id.no_data_tv)).check(matches(withText("No Data")));

     onView(withId(R.id.no_data_tv)).perform(typeText("No Data"));
   }
}

Зависимости файла Gradle:

android {
    defaultConfig {
       testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunne"
    }

    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestUtil 'androidx.test:orchestrator:1.1.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
}

1 Ответ

0 голосов
/ 23 января 2019

У вас есть опечатка в вашем defaultConfig. Вероятно, должно быть:

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...