mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Make emulator tests more stable (#8124)
This commit is contained in:
committed by
GitHub
parent
84b596bffd
commit
cafb52766b
2
.github/workflows/checks.yml
vendored
2
.github/workflows/checks.yml
vendored
@ -154,7 +154,7 @@ jobs:
|
||||
if: failure()
|
||||
with:
|
||||
name: test-report
|
||||
path: app/build/reports/androidTests/connected/flavors/PLAY/
|
||||
path: app/build/reports/androidTests/
|
||||
|
||||
ci-summary:
|
||||
name: "CI Summary"
|
||||
|
||||
10
.github/workflows/runEmulatorTests.sh
vendored
10
.github/workflows/runEmulatorTests.sh
vendored
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o pipefail
|
||||
adb logcat -c
|
||||
|
||||
runTests() {
|
||||
./gradlew connectedPlayDebugAndroidTest connectedDebugAndroidTest \
|
||||
@ -8,4 +9,11 @@ runTests() {
|
||||
}
|
||||
|
||||
# Retry tests to make them less flaky
|
||||
runTests || runTests || runTests
|
||||
if runTests || runTests || runTests; then
|
||||
echo "Tests succeeded"
|
||||
else
|
||||
echo "Tests FAILED. Dumping logcat:"
|
||||
adb logcat -d > app/build/reports/androidTests/logcat.txt
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -99,9 +99,8 @@ public class EspressoTestUtils {
|
||||
*
|
||||
* @param viewMatcher The view to wait for.
|
||||
* @param timeoutMillis Maximum waiting period in milliseconds.
|
||||
* @throws Exception Throws an Exception in case of a timeout.
|
||||
*/
|
||||
public static void waitForViewGlobally(@NonNull Matcher<View> viewMatcher, long timeoutMillis) throws Exception {
|
||||
public static void waitForViewGlobally(@NonNull Matcher<View> viewMatcher, long timeoutMillis) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
long endTime = startTime + timeoutMillis;
|
||||
|
||||
@ -110,14 +109,21 @@ public class EspressoTestUtils {
|
||||
onView(viewMatcher).check(matches(isDisplayed()));
|
||||
// no Exception thrown -> check successful
|
||||
return;
|
||||
} catch (NoMatchingViewException | AssertionFailedError ignore) {
|
||||
} catch (NoMatchingViewException | AssertionFailedError exception) {
|
||||
// check was not successful "not found" -> continue waiting
|
||||
if (System.currentTimeMillis() >= endTime) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
//noinspection BusyWait
|
||||
Thread.sleep(50);
|
||||
} while (System.currentTimeMillis() < endTime);
|
||||
try {
|
||||
//noinspection BusyWait
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
throw new Exception("Timeout after " + timeoutMillis + " ms");
|
||||
throw new RuntimeException("Timeout after " + timeoutMillis + " ms");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package de.danoeh.antennapod;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.StrictMode;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
@ -19,19 +18,6 @@ public class PodcastApp extends Application {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new CrashReportExceptionHandler());
|
||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder()
|
||||
.penaltyDeath()
|
||||
.penaltyLog()
|
||||
.detectLeakedSqlLiteObjects()
|
||||
.detectActivityLeaks()
|
||||
.detectLeakedRegistrationObjects();
|
||||
if (android.os.Build.VERSION.SDK_INT >= 26) {
|
||||
builder.detectContentUriWithoutPermission();
|
||||
}
|
||||
StrictMode.setVmPolicy(builder.build());
|
||||
}
|
||||
|
||||
try {
|
||||
// Robolectric calls onCreate for every test, which causes problems with static members
|
||||
EventBus.builder()
|
||||
|
||||
Reference in New Issue
Block a user