Skip to content

Commit 14feae8

Browse files
committed
android-interop-testing: migrate AndroidJUnit4 runner
1 parent 9ee0ac2 commit 14feae8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

android-interop-testing/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ dependencies {
7676

7777
compileOnly libraries.javax_annotation
7878

79-
androidTestImplementation 'androidx.test:rules:1.1.0-alpha1'
80-
androidTestImplementation 'androidx.test:runner:1.1.0-alpha1'
79+
androidTestImplementation 'androidx.test.ext:junit:1.1.3',
80+
'androidx.test:runner:1.4.0'
8181
}
8282

8383
// Checkstyle doesn't run automatically with android

android-interop-testing/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616

1717
package io.grpc.android.integrationtest;
1818

19-
import static junit.framework.Assert.assertEquals;
19+
import static org.junit.Assert.assertEquals;
2020

2121
import android.util.Log;
22-
import androidx.test.InstrumentationRegistry;
23-
import androidx.test.runner.AndroidJUnit4;
22+
import androidx.test.core.app.ApplicationProvider;
23+
import androidx.test.ext.junit.runners.AndroidJUnit4;
24+
import androidx.test.platform.app.InstrumentationRegistry;
2425
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
2526
import com.google.android.gms.common.GooglePlayServicesRepairableException;
2627
import com.google.android.gms.security.ProviderInstaller;
@@ -59,7 +60,7 @@ public void setUp() throws Exception {
5960

6061
if (useTls) {
6162
try {
62-
ProviderInstaller.installIfNeeded(InstrumentationRegistry.getTargetContext());
63+
ProviderInstaller.installIfNeeded(ApplicationProvider.getApplicationContext());
6364
} catch (GooglePlayServicesRepairableException e) {
6465
// The provider is helpful, but it is possible to succeed without it.
6566
// Hope that the system-provided libraries are new enough.
@@ -110,7 +111,7 @@ public void onComplete(String result) {
110111
};
111112
InputStream testCa;
112113
if (useTestCa) {
113-
testCa = InstrumentationRegistry.getTargetContext().getResources().openRawResource(R.raw.ca);
114+
testCa = ApplicationProvider.getApplicationContext().getResources().openRawResource(R.raw.ca);
114115
} else {
115116
testCa = null;
116117
}

0 commit comments

Comments
 (0)