Я пытаюсь реализовать вещи из этого примера - https://github.com/googlesamples/android-testing/tree/master/ui/espresso/BasicSample - в свое приложение.Тест для эспрессо Android: Класс не найден: ... Пустой набор тестов
Когда я пытаюсь выполнить простой тест Эспрессо, это происходит:
"/ Applications/Android Студия 2.2.3.app/Contents/jre/jdk/Contents/Home/bin/java" (...)
Процесс завершен с кодом выхода 1 Класс не найден: «com.faces_shop.app.MainActivityTest» Пустой набор тестов.
(копия-вставили из Android Studio)
Тест:
package com.faces_shop.app;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
/**
* Created by AnonymizedForReview on 2017-01-12.
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
public static final String STRING_TO_BE_TYPED = "Espresso";
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
@Test
public void changeText_sameActivity() {
// Type text and then press the button.
onView(withId(R.id.editFilter))
.perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard());
// onView(withId(R.id.changeTextBt)).perform(click());
// Check that the text was changed.
onView(withId(R.id.editFilter)).check(matches(withText(STRING_TO_BE_TYPED)));
}
}
build.gradle для приложения:
apply plugin: 'com.android.application'
android {
// productFlavors {
// /* https://android-developers.googleblog.com/2015/12/leveraging-product-flavors-in-android.html */
// mock {
// applicationIdSuffix = ".mock"
// }
// prod
// }
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.faces_shop.app"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':FacesApi')
// androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// exclude group: 'com.android.support', module: 'support-annotations'
// })
// Testing-only dependencies
// Force usage of support annotations in the test app, since it is internally used by the runner module.
androidTestCompile 'com.android.support:support-annotations:' + rootProject.supportLibVersion;
androidTestCompile 'com.android.support.test:runner:' + rootProject.runnerVersion;
androidTestCompile 'com.android.support.test:rules:' + rootProject.rulesVersion;
androidTestCompile 'com.android.support.test.espresso:espresso-core:' + rootProject.espressoVersion;
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
верхнего уровня build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
ext {
buildToolsVersion = "24.0.1"
supportLibVersion = "25.0.1"
runnerVersion = "0.5"
rulesVersion = "0.5"
espressoVersion = "2.2.2"
}
Что я делаю неправильно?
Почему класс испытания не виден?
Именно в этом направлении в androidTest: .../Примеры/DynamicList/FacesApp/SRC/androidTest/Java/COM/faces_shop/приложение/MainActivityTest.java
Запуск '../gradlew connectedCheck' ** выполняет ** поиск и запуск теста. Поэтому я полагаю, что проблема в Android Studio. Уборка/перестройка в Android Studio не помогла. Перезагрузка Android Studio тоже не помогла. – KarolDepka