diff --git a/AndroidTestingBlueprint/README.md b/AndroidTestingBlueprint/README.md index 126ab9b..0efef4d 100644 --- a/AndroidTestingBlueprint/README.md +++ b/AndroidTestingBlueprint/README.md @@ -8,9 +8,9 @@ A collection of Google's Android testing tools and frameworks, all integrated in - `app/test/` - Unit tests - `app/androidTest/` - Instrumentation tests - `app/androidTestFlavor2/` - Additional Instrumentation tests for Flavor2. -- `module-flavor1-androidTest-only/` - Test-only module with Instrumentation tests for Flavor1 - `module-android-library/` - An Android module (typically a library) - `module-android-library/androidTest` - Android Tests for the module-android-library +- `module-flavor1-androidTest-only/` - Test-only module with Instrumentation tests for Flavor1 - `module-plain-java/` - A Java module for non-Android code (business logic, utils classes, etc.) - `module-plain-java/test` - Unit tests for module-plain-java @@ -226,7 +226,7 @@ See [AndroidJUnitRunner](http://developer.android.com/reference/android/support/ - Stack Overflow: http://stackoverflow.com/questions/tagged/android-testing If you've found an error in this sample, please file an issue: -https://github.com/googlesamples/android-testing-blueprint +https://github.com/googlesamples/android-testing-templates/issues ## Contributions Patches are encouraged, and may be submitted by forking this project and diff --git a/AndroidTestingBlueprint/app/build.gradle b/AndroidTestingBlueprint/app/build.gradle index 1a7b53a..93b143a 100644 --- a/AndroidTestingBlueprint/app/build.gradle +++ b/AndroidTestingBlueprint/app/build.gradle @@ -2,14 +2,6 @@ apply plugin: 'com.android.application' android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion - - /* - Test only modules require other artifacts like the classes.jar to be published, so the test can - reference the tested java sources and compile them correctly. In order to get all these - artifacts published from the tested module publishNonDefault needs to be set to true. - */ - publishNonDefault true defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -54,6 +46,8 @@ android { } } + flavorDimensions "defaultDimension" + productFlavors { flavor1 { applicationId 'com.example.android.testing.blueprint.flavor1' @@ -74,34 +68,34 @@ android { dependencies { // App's dependencies, including test - compile 'com.android.support:appcompat-v7:' + rootProject.ext.supportLibVersion + implementation 'com.android.support:appcompat-v7:' + rootProject.ext.supportLibVersion - compile project(':module-plain-java') // Optional module for non-Android code - compile project(':module-android-library') // Optional module for additional Android code + implementation project(':module-plain-java') // Optional module for non-Android code + implementation project(':module-android-library') // Optional module for additional Android code // Dependencies for local unit tests - testCompile 'junit:junit:' + rootProject.ext.junitVersion - testCompile 'org.mockito:mockito-all:' + rootProject.ext.mockitoVersion - testCompile 'org.hamcrest:hamcrest-all:' + rootProject.ext.hamcrestVersion + testImplementation 'junit:junit:' + rootProject.ext.junitVersion + testImplementation 'org.mockito:mockito-all:' + rootProject.ext.mockitoVersion + testImplementation 'org.hamcrest:hamcrest-all:' + rootProject.ext.hamcrestVersion // Android Testing Support Library's runner and rules - androidTestCompile 'com.android.support.test:runner:' + rootProject.ext.runnerVersion - androidTestCompile 'com.android.support.test:rules:' + rootProject.ext.rulesVersion + androidTestImplementation 'com.android.support.test:runner:' + rootProject.ext.runnerVersion + androidTestImplementation 'com.android.support.test:rules:' + rootProject.ext.rulesVersion // Espresso UI Testing - androidTestCompile 'com.android.support.test.espresso:espresso-core:' + rootProject.ext.espressoVersion + androidTestImplementation 'com.android.support.test.espresso:espresso-core:' + rootProject.ext.espressoVersion // Espresso-Contrib, Intents and Web dependencies are not used in this project. /* - androidTestCompile 'com.android.support.test.espresso:espresso-contrib:' + rootProject.ext.espressoVersion - androidTestCompile 'com.android.support.test.espresso:espresso-intents:' + rootProject.ext.espressoVersion - androidTestCompile 'com.android.support.test.espresso:espresso-web:' + rootProject.ext.espressoVersion + androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:' + rootProject.ext.espressoVersion + androidTestImplementation 'com.android.support.test.espresso:espresso-intents:' + rootProject.ext.espressoVersion + androidTestImplementation 'com.android.support.test.espresso:espresso-web:' + rootProject.ext.espressoVersion */ // UIAutomator Testing. Learn about this dependency in this projects README file. - androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:' + rootProject.ext.uiautomatorVersion + androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:' + rootProject.ext.uiautomatorVersion // Resolve conflicts between main and test APK: - androidTestCompile "com.android.support:support-annotations:$rootProject.supportLibVersion" + androidTestImplementation "com.android.support:support-annotations:$rootProject.supportLibVersion" } diff --git a/AndroidTestingBlueprint/build.gradle b/AndroidTestingBlueprint/build.gradle index da60679..3218402 100644 --- a/AndroidTestingBlueprint/build.gradle +++ b/AndroidTestingBlueprint/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,16 +16,16 @@ buildscript { allprojects { repositories { jcenter() + google() } } ext { - minSdkVersion = 10 - targetSdkVersion = 25 - compileSdkVersion = 25 - buildToolsVersion = "25.0.1" + minSdkVersion = 14 + targetSdkVersion = 27 + compileSdkVersion = 27 - supportLibVersion = "25.0.1" + supportLibVersion = "27.0.1" junitVersion = "4.12" mockitoVersion = "1.10.19" hamcrestVersion = "1.3" diff --git a/AndroidTestingBlueprint/gradle/wrapper/gradle-wrapper.properties b/AndroidTestingBlueprint/gradle/wrapper/gradle-wrapper.properties index 1bbecb9..abd2403 100644 --- a/AndroidTestingBlueprint/gradle/wrapper/gradle-wrapper.properties +++ b/AndroidTestingBlueprint/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip diff --git a/AndroidTestingBlueprint/module-android-library/build.gradle b/AndroidTestingBlueprint/module-android-library/build.gradle index 8732f6c..9d11acd 100644 --- a/AndroidTestingBlueprint/module-android-library/build.gradle +++ b/AndroidTestingBlueprint/module-android-library/build.gradle @@ -2,7 +2,6 @@ apply plugin: 'com.android.library' android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -21,6 +20,6 @@ android { dependencies { // Android Testing Support Library's runner and rules - androidTestCompile 'com.android.support.test:runner:' + rootProject.ext.runnerVersion - androidTestCompile 'com.android.support.test:rules:' + rootProject.ext.rulesVersion + androidTestImplementation 'com.android.support.test:runner:' + rootProject.ext.runnerVersion + androidTestImplementation 'com.android.support.test:rules:' + rootProject.ext.rulesVersion } diff --git a/AndroidTestingBlueprint/module-flavor1-androidTest-only/build.gradle b/AndroidTestingBlueprint/module-flavor1-androidTest-only/build.gradle index ef92aa7..955532c 100644 --- a/AndroidTestingBlueprint/module-flavor1-androidTest-only/build.gradle +++ b/AndroidTestingBlueprint/module-flavor1-androidTest-only/build.gradle @@ -2,12 +2,14 @@ apply plugin: 'com.android.test' // A plugin used for test-only-modules android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion + // Only include the 'flavor1' product flavor from the 'defaultDimension' flavor dimension + missingDimensionStrategy 'defaultDimension', 'flavor1' + // The package name of the test app testApplicationId 'com.example.android.testing.blueprint.test' // The Instrumentation test runner used to run tests. @@ -17,12 +19,11 @@ android { // Set the target app project. The module specified here should contain the production code // test should run against. targetProjectPath ':app' - targetVariant 'flavor1Debug' } dependencies { // Android Testing Support Library's runner and rules and hamcrest matchers - compile 'com.android.support.test:runner:' + rootProject.ext.runnerVersion - compile 'com.android.support.test:rules:' + rootProject.ext.rulesVersion - compile 'org.hamcrest:hamcrest-core:' + rootProject.ext.hamcrestVersion + implementation 'com.android.support.test:runner:' + rootProject.ext.runnerVersion + implementation 'com.android.support.test:rules:' + rootProject.ext.rulesVersion + implementation 'org.hamcrest:hamcrest-core:' + rootProject.ext.hamcrestVersion }