Skip to content

Commit 9d97c50

Browse files
Piotr Zawadzkizawadz88
authored andcommitted
#1 Added AndroidX support + library update to 2.0.0
1 parent 0d5efcf commit 9d97c50

15 files changed

Lines changed: 63 additions & 55 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [2.0.0]
8+
### Changed
9+
Migrated to AndroidX and Android Test Runner 1.1.0
10+
711
## [1.0.0]
812
### Added
913
Initial release of the library.
1014

15+
[2.0.0]: https://github.com/stepstone-tech/AndroidTestXRunner/compare/1.0.0...2.0.0
1116
[1.0.0]: https://github.com/stepstone-tech/AndroidTestXRunner/tree/1.0.0

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ It heavily depends on [Android Test Orchestrator](https://medium.com/stepstone-t
1515
### 1. Add a Gradle dependency in your `build.gradle`
1616

1717
```groovy
18-
implementation 'com.stepstone.xrunner:xrunner-library:1.0.0'
18+
implementation 'com.stepstone.xrunner:xrunner-library:2.0.0'
1919
```
2020

21+
*NOTE:* not on AndroidX yet? See *Compatibility* section at the bottom.
22+
2123
### 2. Use AndroidJUnitXRunner instead of your runner
2224

2325
In your app's `build.gradle` file add the following:
@@ -39,12 +41,12 @@ XRunner relies on Android Test Orchestrator therefore Android Test Orchestrator
3941
android {
4042
4143
testOptions {
42-
execution 'ANDROID_TEST_ORCHESTRATOR'
44+
execution 'ANDROIDX_TEST_ORCHESTRATOR'
4345
}
4446
}
4547
4648
dependencies {
47-
androidTestUtil 'com.android.support.test:orchestrator:1.0.2'
49+
androidTestUtil 'androidx.test:orchestrator:1.1.0'
4850
}
4951
```
5052

@@ -81,6 +83,7 @@ Here are some samples:
8183

8284
# Compatibility
8385

84-
| XRunner version | Test runner version |
85-
|:---------------:|:---------------------------------------:|
86-
| 1.0.0 | `com.android.support.test:runner:1.0.2` |
86+
| XRunner version | Test runner version |
87+
|:------------------------------------------------------------------------:|:---------------------------------------:|
88+
| [2.0.0](https://github.com/stepstone-tech/AndroidTestXRunner/tree/2.0.0) | `androidx.test:runner:1.1.0` |
89+
| [1.0.0](https://github.com/stepstone-tech/AndroidTestXRunner/tree/1.0.0) | `com.android.support.test:runner:1.0.2` |

app/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ android {
2121
}
2222
}
2323
testOptions {
24-
execution 'ANDROID_TEST_ORCHESTRATOR'
24+
execution 'ANDROIDX_TEST_ORCHESTRATOR'
2525
animationsDisabled = true
2626
}
2727
}
2828

2929
dependencies {
3030
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
31-
implementation "com.android.support:appcompat-v7:$APPCOMPAT_VERSION"
32-
implementation "com.android.support.constraint:constraint-layout:$CONSTRAINT_VERSION"
33-
implementation "com.android.support:design:$DESIGN_VERSION"
31+
implementation "androidx.appcompat:appcompat:$APPCOMPAT_VERSION"
32+
implementation "androidx.constraintlayout:constraintlayout:$CONSTRAINT_VERSION"
33+
implementation "com.google.android.material:material:$MATERIAL_VERSION"
3434

3535
androidTestImplementation project(':xrunner-library')
3636

37-
androidTestImplementation "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
38-
androidTestImplementation "com.android.support.test:rules:$TEST_RULES_VERSION"
39-
androidTestUtil "com.android.support.test:orchestrator:$TEST_ORCHESTRATOR_VERSION"
37+
androidTestImplementation "androidx.test.ext:junit:$TEST_EXT_VERSION"
38+
androidTestImplementation "androidx.test.espresso:espresso-core:$ESPRESSO_VERSION"
39+
androidTestImplementation "androidx.test:rules:$TEST_RULES_VERSION"
40+
androidTestUtil "androidx.test:orchestrator:$TEST_ORCHESTRATOR_VERSION"
4041
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stepstone.xrunner.sample
22

3-
import android.support.test.InstrumentationRegistry
4-
import android.support.test.runner.AndroidJUnit4
3+
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import androidx.test.platform.app.InstrumentationRegistry
55
import org.junit.Assert.assertEquals
66
import org.junit.Test
77
import org.junit.runner.RunWith
@@ -12,7 +12,7 @@ class ExampleInstrumentedTest {
1212
@Test
1313
fun useAppContext() {
1414
// Context of the app under test.
15-
val appContext = InstrumentationRegistry.getTargetContext()
15+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
1616
assertEquals("com.stepstone.xrunner.sample", appContext.packageName)
1717
}
1818
}

app/src/androidTest/java/com/stepstone/xrunner/sample/MainActivityTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.stepstone.xrunner.sample
22

3-
import android.support.test.espresso.Espresso.onView
4-
import android.support.test.espresso.action.ViewActions.click
5-
import android.support.test.espresso.assertion.ViewAssertions.matches
6-
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
7-
import android.support.test.espresso.matcher.ViewMatchers.withId
8-
import android.support.test.espresso.matcher.ViewMatchers.withText
9-
import android.support.test.rule.ActivityTestRule
10-
import android.support.test.runner.AndroidJUnit4
3+
import androidx.test.espresso.Espresso.onView
4+
import androidx.test.espresso.action.ViewActions.click
5+
import androidx.test.espresso.assertion.ViewAssertions.matches
6+
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
7+
import androidx.test.espresso.matcher.ViewMatchers.withId
8+
import androidx.test.espresso.matcher.ViewMatchers.withText
9+
import androidx.test.ext.junit.runners.AndroidJUnit4
10+
import androidx.test.rule.ActivityTestRule
1111
import org.hamcrest.Matchers.not
1212
import org.junit.Assert.assertTrue
1313
import org.junit.Ignore
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stepstone.xrunner.sample.dummy
22

3-
import android.support.test.InstrumentationRegistry
4-
import android.support.test.runner.AndroidJUnit4
3+
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import androidx.test.platform.app.InstrumentationRegistry
55
import org.junit.Assert.assertEquals
66
import org.junit.Test
77
import org.junit.runner.RunWith
@@ -12,7 +12,7 @@ class ExampleInstrumentedTest {
1212
@Test
1313
fun useAppContext() {
1414
// Context of the app under test.
15-
val appContext = InstrumentationRegistry.getTargetContext()
15+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
1616
assertEquals("com.stepstone.xrunner.sample", appContext.packageName)
1717
}
1818
}

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
android:name=".MainActivity"
1414
android:label="@string/title_activity_main"
1515
android:theme="@style/AppTheme.NoActionBar">
16-
<meta-data
17-
android:name="android.support.PARENT_ACTIVITY"
18-
android:value="android.support.v7.app.AppCompatActivity" />
19-
2016
<intent-filter>
2117
<action android:name="android.intent.action.MAIN" />
2218

app/src/main/java/com/stepstone/xrunner/sample/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stepstone.xrunner.sample
22

33
import android.os.Bundle
4-
import android.support.v7.app.AppCompatActivity
4+
import androidx.appcompat.app.AppCompatActivity
55
import android.view.View
66
import kotlinx.android.synthetic.main.activity_main.fab
77
import kotlinx.android.synthetic.main.activity_main.toolbar
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
tools:context=".MainActivity">
88

9-
<android.support.design.widget.AppBarLayout
9+
<com.google.android.material.appbar.AppBarLayout
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
1212
android:theme="@style/AppTheme.AppBarOverlay">
1313

14-
<android.support.v7.widget.Toolbar
14+
<androidx.appcompat.widget.Toolbar
1515
android:id="@+id/toolbar"
1616
android:layout_width="match_parent"
1717
android:layout_height="?attr/actionBarSize"
1818
android:background="?attr/colorPrimary"
1919
app:popupTheme="@style/AppTheme.PopupOverlay" />
2020

21-
</android.support.design.widget.AppBarLayout>
21+
</com.google.android.material.appbar.AppBarLayout>
2222

2323
<include layout="@layout/content_main" />
2424

25-
<android.support.design.widget.FloatingActionButton
25+
<com.google.android.material.floatingactionbutton.FloatingActionButton
2626
android:id="@+id/fab"
2727
android:layout_width="wrap_content"
2828
android:layout_height="wrap_content"
2929
android:layout_gravity="bottom|end"
3030
android:layout_margin="@dimen/fab_margin"
3131
app:srcCompat="@android:drawable/ic_menu_info_details" />
3232

33-
</android.support.design.widget.CoordinatorLayout>
33+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

app/src/main/res/layout/content_main.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
@@ -23,4 +23,4 @@
2323
app:layout_constraintStart_toStartOf="parent"
2424
app:layout_constraintTop_toTopOf="parent" />
2525

26-
</android.support.constraint.ConstraintLayout>
26+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)