Utworzono domyślny pusty projekt na Android Studio 2.1.2 z API 24. W projekcie próbki, Google oferuje zamortyzowanego klasa ApplicationTestCase:ApplicationTestCase przestarzałe w poziomie API 24
This class was deprecated in API level 24. Use ActivityTestRule instead. New tests should be written using the Android Testing Support Library.
Próbka:
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
Moje pytanie: Dlaczego Android Przypadek Testowy jest teraz przestarzała? Jak zastąpić ApplicationTestCase przez ActivityTestRule?
EDIT:
próbuję z Expresso, ale na API 24 (compileSdkVersion 24
) Mam ten błąd:
Error:Conflict with dependency 'com.android.support:appcompat-v7'. Resolved versions for app (24.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:design'. Resolved versions for app (24.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (24.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:recyclerview-v7'. Resolved versions for app (24.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Gdy próbuję dodać ten lib w moim build.gradle:
// Android JUnit Runner
androidTestCompile 'com.android.support.test:runner:0.5'
// JUnit4 Rules
androidTestCompile 'com.android.support.test:rules:0.5'
// Espresso core
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
// Espresso-web for WebView support
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
// Espresso-idling-resource for synchronization with background jobs
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
My conclusion is that for the moment neither Android Test Case nor Expresso works on Android API 24. Is this right?
EDIT: 2016-08-05
naprawić poprzedni błąd na Expresso tak:
def espressoVersion = '2.2.2'
def testRunnerVersion = '0.5'
androidTestCompile "com.android.support.test:rules:${testRunnerVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-core:${espressoVersion}"
configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
androidTestCompileDependency.exclude group: 'com.android.support'
}
googlowania "Android espresso" – hanbumpark
@HanbumBak nie mogę znaleźć tutorial Api 24 –
Odnośnie błędu konfliktu zależność patrz: [Ta odpowiedź] (http://stackoverflow.com/questions/38181587/android-version-24-0-0-and-espresso-2-0-gradle-exception/38182270#38182270) – thaussma