Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gradle, kotlin, libraries and Migrate Project to AndroidX #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions AndroidTestingBlueprint-kotlinApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
versionCode 1
versionName '1.0'

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
/*
The Android Testing Support Library collects analytics to continuously improve the testing
experience. More specifically, it uploads a hash of the package name of the application
Expand Down Expand Up @@ -72,8 +72,8 @@ android {

dependencies {
// App's dependencies, including test
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

implementation project(':module-plain-kotlin') // Optional module for non-Android code
implementation project(':module-android-library') // Optional module for additional Android code
Expand All @@ -84,11 +84,11 @@ dependencies {
testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"

// Android Testing Support Library's runner and rules
androidTestImplementation "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestImplementation "com.android.support.test:rules:$rootProject.ext.rulesVersion"
androidTestImplementation "androidx.test.ext:junit:1.1.1"
androidTestImplementation "androidx.test:rules:$rulesVersion"

// Espresso UI Testing
androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"

// Espresso-Contrib, Intents and Web dependencies are not used in this project.
/*
Expand All @@ -98,9 +98,9 @@ dependencies {
*/

// UIAutomator Testing. Learn about this dependency in this projects README file.
androidTestImplementation "com.android.support.test.uiautomator:uiautomator-v18:$rootProject.ext.uiautomatorVersion"
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'

// Resolve conflicts between main and test APK:
androidTestImplementation "com.android.support:support-annotations:$rootProject.supportLibVersion"
androidTestImplementation 'androidx.annotation:annotation:1.1.0'

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.example.android.testing.blueprint.integration

import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.InstrumentationRegistry.getTargetContext
import android.support.test.runner.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.platform.app.InstrumentationRegistry.getTargetContext
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.android.testing.blueprint.R
import com.example.android.testing.blueprint.androidlibrarymodule.AndroidLibraryModuleClass
import org.hamcrest.CoreMatchers.equalTo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package com.example.android.testing.blueprint.ui.espresso

import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.click
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.espresso.matcher.ViewMatchers.withText
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.rule.ActivityTestRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.android.testing.blueprint.HelloTestingBlueprintActivity
import com.example.android.testing.blueprint.R
import org.junit.Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package com.example.android.testing.blueprint.ui.uiautomator
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.support.test.InstrumentationRegistry
import android.support.test.filters.SdkSuppress
import android.support.test.runner.AndroidJUnit4
import android.support.test.uiautomator.By
import android.support.test.uiautomator.UiDevice
import android.support.test.uiautomator.Until
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.filters.SdkSuppress
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import com.example.android.testing.blueprint.R
import org.hamcrest.Matchers.notNullValue
import org.junit.Assert.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.example.android.testing.blueprint

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import android.view.View
import android.widget.TextView

Expand Down
14 changes: 7 additions & 7 deletions AndroidTestingBlueprint-kotlinApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
buildscript {
ext {
minSdkVersion = 14
targetSdkVersion = 27
compileSdkVersion = 27
targetSdkVersion = 29
compileSdkVersion = 29

kotlinVersion = "1.2.0"
supportLibVersion = "27.0.2"
kotlinVersion = "1.3.50"
appcompatVersion = "1.1.0"
junitVersion = "4.12"
mockitoVersion = "1.10.19"
hamcrestVersion = "1.3"
runnerVersion = "0.5"
rulesVersion = "0.5"
espressoVersion = "2.2.2"
rulesVersion = "1.2.0"
espressoVersion = "3.2.0"
uiautomatorVersion = "2.1.2"
}

Expand All @@ -23,7 +23,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 3 additions & 1 deletion AndroidTestingBlueprint-kotlinApp/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Dec 06 13:05:10 GMT 2016
#Thu Nov 14 21:02:05 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
versionCode 1
versionName "1.0"

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

// Define ProGuard rules for this android library project. These rules will be applied when
// a consumer of this library sets 'minifyEnabled true'.
Expand All @@ -20,9 +20,9 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

// Android Testing Support Library's runner and rules
androidTestImplementation "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestImplementation "com.android.support.test:rules:$rootProject.ext.rulesVersion"
androidTestImplementation "androidx.test.ext:junit:1.1.1"
androidTestImplementation "androidx.test:rules:$rulesVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.example.android.testing.blueprint.androidlibrarymodule

import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
// The package name of the test app
testApplicationId 'com.example.android.testing.blueprint.test'
// The Instrumentation test runner used to run tests.
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

// Set the target app project. The module specified here should contain the production code
Expand All @@ -24,8 +24,8 @@ android {

dependencies {
// Android Testing Support Library's runner and rules and hamcrest matchers
implementation "com.android.support.test:runner:$rootProject.ext.runnerVersion"
implementation "com.android.support.test:rules:$rootProject.ext.rulesVersion"
implementation "androidx.test.ext:junit:1.1.1"
implementation "androidx.test:rules:$rulesVersion"
implementation "org.hamcrest:hamcrest-core:$rootProject.ext.hamcrestVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
package="com.example.android.testing.blueprint.test">

<!-- Specify runner and target application package -->
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.example.android.testing.blueprint.flavor1"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.example.android.testing.blueprint.test

import android.content.Context
import android.support.test.InstrumentationRegistry.getTargetContext
import android.support.test.runner.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.example.android.testing.blueprint.R
import junit.framework.Assert.assertEquals
import org.junit.Before
Expand All @@ -35,7 +35,7 @@ class AndroidTestOnlyModuleTest {

@Before fun initTargetContext() {
// Obtain the target context from InstrumentationRegistry
context = getTargetContext()
context = InstrumentationRegistry.getInstrumentation().targetContext
}

@Test fun verifyResourceString() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
apply plugin: 'kotlin'

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

// Dependencies for local unit tests
testCompile 'junit:junit:' + rootProject.ext.junitVersion
testCompile 'org.hamcrest:hamcrest-core:' + rootProject.ext.hamcrestVersion

testImplementation 'junit:junit:' + rootProject.ext.junitVersion
testImplementation 'org.hamcrest:hamcrest-core:' + rootProject.ext.hamcrestVersion
}