Android Studion 2.2.3Android. @RunWith (AndroidJUnit4.class) - невозможно решить в пакете «androidTest»
Установить Android Support Repository - вер. 44.0.0
установки я все как в официальном сайте для Эспрессо:
https://google.github.io/android-testing-support-library/docs/espresso/setup/index.html
Я пытаюсь написать Контрольно-измерительные приборы (Espresso) в пакете androidTest. Поэтому я создаю StringUtilAndroidTest в папке SRC/androidTest/Java/COM/моякомп/
Мои StringUtilAndroidTest код:
@RunWith(AndroidJUnit4.class)
@LargeTest
public class StringUtilAndroidTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule(MainActivity.class);
@Test
public void myTest() {
assert(true);
}
}
В моей build.gradle:
android.defaultconfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
мои зависимости:
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1
Но в StringUtilAndroidTest я получаю компиляции ошибка:
@RunWith(AndroidJUnit4.class)
не удается разрешить символ RunWith
Почему?
Помимо добавления линий androidTestCompile в ваш build.gradle, вы также не забыли импортировать класс поверх файла Java? то есть 'import org.junit.runner.RunWith;' – Bill
import org.junit.runner.RunWith; - не удается разрешить символ «RunWith» – Alexei