Robolectric не найденоAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Robolectric не найдено

Сообщение Anonymous »

Я начал с Robolectric в Android Studio.
я бы запустил простой пример, но у меня есть эта ошибка < /p>

Запуск тестов
test. android.test.androidtestrunner.runtest (androidtestrunner.java:191)
at android.test.androidtestrunner.runtest (androidtestrunner.java:176)
at android.test.instrupationtestrunner.onstart (intrementTestrunner. Android.App.instrumentation $ IntrementationThread.Run (Инструментация@RunWith(RobolectricTestRunner.class)
public class AuthenticationActivityTest {

@Test
public void checkAccountType() throws Exception{
String accType = new AuthenticationActivity().getResources().getString(R.string.account_type);
assertThat(accType,equalTo("com.example.myApp"));
}
}
< /code>

File Gradle < /h2>

apply plugin: 'com.android.application'
apply plugin: 'org.robolectric' //Robolectric

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.example.myApp"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
androidTestCompile 'junit:junit:4.12' //Robolectric
androidTestCompile 'org.robolectric:robolectric:2.4' //Robolectric
}
< /code>

update < /h1>

Когда я добавляю testinstrumentationrunner в конфигурации по умолчанию в Gradle Like: < /p>

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
< /code>

Роболектические тесты становятся признанными, но я получил эту ошибку: < /p>

com.example.myApp.AuthenticationActivityTest > testAccountType[small(AVD) - 5.0.2] FAILED
java.lang.NullPointerException: parentLoader == null && !nullAllowed
at java.lang.ClassLoader.(ClassLoader.java:210)
:app:connectedAndroidTest FAILED


Подробнее здесь: https://stackoverflow.com/questions/292 ... ests-found
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»