Skip to content

Commit 886e2bd

Browse files
committed
test: migrate to androidx
1 parent 5fa40b2 commit 886e2bd

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

app/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ android {
1010
targetSdkVersion 35
1111
versionCode 1000007
1212
versionName "1.0.7-SNAPSHOT"
13+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1314
}
1415

1516
buildTypes {
@@ -29,8 +30,13 @@ android {
2930

3031
dependencies {
3132
implementation fileTree(dir: 'libs', include: ['*.jar'])
32-
testImplementation 'junit:junit:4.13.2'
33+
3334
implementation 'com.android.support:appcompat-v7:28.0.0'
35+
36+
testImplementation 'junit:junit:4.13.2'
37+
38+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
39+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
3440
}
3541

3642
publishing {

app/src/androidTest/java/ai/elimu/keyboard/ApplicationTest.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ai.elimu.keyboard;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
25+
assertEquals("ai.elimu.keyboard.debug", appContext.getPackageName());
26+
}
27+
}

gradle.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
# org.gradle.parallel=true
19+
20+
# AndroidX package structure to make it clearer which packages are bundled with the
21+
# Android operating system, and which are packaged with your app's APK
22+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
23+
android.useAndroidX=true

0 commit comments

Comments
 (0)