Skip to content

Commit 2840bca

Browse files
committed
Add @afterclass & @after to tests missing this
* This ensure we are cleaning things up before going to the next test * This along with the last commit should help prevent the stalling issue we have been seeing.
1 parent 49eedfe commit 2840bca

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

OneSignalSDK/unittest/src/test/java/com/test/onesignal/DeviceTypeTestsRunner.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.onesignal.ShadowOSUtils;
77
import com.onesignal.StaticResetHelper;
88

9+
import org.junit.After;
10+
import org.junit.AfterClass;
911
import org.junit.Before;
1012
import org.junit.BeforeClass;
1113
import org.junit.Test;
@@ -43,6 +45,16 @@ public void beforeEachTest() throws Exception {
4345
OneSignal.initWithContext(ApplicationProvider.getApplicationContext());
4446
}
4547

48+
@AfterClass
49+
public static void afterEverything() throws Exception {
50+
TestHelpers.beforeTestInitAndCleanup();
51+
}
52+
53+
@After
54+
public void afterEachTest() throws Exception {
55+
TestHelpers.afterTestCleanup();
56+
}
57+
4658
@Test
4759
public void noAvailablePushChannels_defaultsToAndroid() {
4860
assertEquals(DEVICE_TYPE_ANDROID, getDeviceType());

OneSignalSDK/unittest/src/test/java/com/test/onesignal/GenerateNotificationRunner.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.json.JSONArray;
8787
import org.json.JSONException;
8888
import org.json.JSONObject;
89+
import org.junit.After;
8990
import org.junit.AfterClass;
9091
import org.junit.Before;
9192
import org.junit.BeforeClass;
@@ -216,7 +217,12 @@ public void beforeEachTest() throws Exception {
216217

217218
@AfterClass
218219
public static void afterEverything() throws Exception {
219-
StaticResetHelper.restSetStaticFields();
220+
TestHelpers.beforeTestInitAndCleanup();
221+
}
222+
223+
@After
224+
public void afterEachTest() throws Exception {
225+
TestHelpers.afterTestCleanup();
220226
}
221227

222228
public static Bundle getBaseNotifBundle() {

OneSignalSDK/unittest/src/test/java/com/test/onesignal/NotificationOpenedActivityHMSIntegrationTestsRunner.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
import org.json.JSONException;
2525
import org.json.JSONObject;
26+
import org.junit.After;
27+
import org.junit.AfterClass;
2628
import org.junit.Before;
2729
import org.junit.BeforeClass;
2830
import org.junit.Test;
@@ -84,6 +86,16 @@ public void beforeEachTest() throws Exception {
8486
setRemoteParamsGetHtmlResponse();
8587
}
8688

89+
@AfterClass
90+
public static void afterEverything() throws Exception {
91+
TestHelpers.beforeTestInitAndCleanup();
92+
}
93+
94+
@After
95+
public void afterEachTest() throws Exception {
96+
TestHelpers.afterTestCleanup();
97+
}
98+
8799
private static @NonNull Intent helper_baseHMSOpenIntent() {
88100
return new Intent()
89101
.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK)

0 commit comments

Comments
 (0)