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()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: test-report
|
name: test-report
|
||||||
path: app/build/reports/androidTests/connected/flavors/PLAY/
|
path: app/build/reports/androidTests/
|
||||||
|
|
||||||
ci-summary:
|
ci-summary:
|
||||||
name: "CI Summary"
|
name: "CI Summary"
|
||||||
|
|||||||
10
.github/workflows/runEmulatorTests.sh
vendored
10
.github/workflows/runEmulatorTests.sh
vendored
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
adb logcat -c
|
||||||
|
|
||||||
runTests() {
|
runTests() {
|
||||||
./gradlew connectedPlayDebugAndroidTest connectedDebugAndroidTest \
|
./gradlew connectedPlayDebugAndroidTest connectedDebugAndroidTest \
|
||||||
@ -8,4 +9,11 @@ runTests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Retry tests to make them less flaky
|
# 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 viewMatcher The view to wait for.
|
||||||
* @param timeoutMillis Maximum waiting period in milliseconds.
|
* @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 startTime = System.currentTimeMillis();
|
||||||
long endTime = startTime + timeoutMillis;
|
long endTime = startTime + timeoutMillis;
|
||||||
|
|
||||||
@ -110,14 +109,21 @@ public class EspressoTestUtils {
|
|||||||
onView(viewMatcher).check(matches(isDisplayed()));
|
onView(viewMatcher).check(matches(isDisplayed()));
|
||||||
// no Exception thrown -> check successful
|
// no Exception thrown -> check successful
|
||||||
return;
|
return;
|
||||||
} catch (NoMatchingViewException | AssertionFailedError ignore) {
|
} catch (NoMatchingViewException | AssertionFailedError exception) {
|
||||||
// check was not successful "not found" -> continue waiting
|
// check was not successful "not found" -> continue waiting
|
||||||
|
if (System.currentTimeMillis() >= endTime) {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//noinspection BusyWait
|
try {
|
||||||
Thread.sleep(50);
|
//noinspection BusyWait
|
||||||
} while (System.currentTimeMillis() < endTime);
|
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;
|
package de.danoeh.antennapod;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.material.color.DynamicColors;
|
import com.google.android.material.color.DynamicColors;
|
||||||
@ -19,19 +18,6 @@ public class PodcastApp extends Application {
|
|||||||
Thread.setDefaultUncaughtExceptionHandler(new CrashReportExceptionHandler());
|
Thread.setDefaultUncaughtExceptionHandler(new CrashReportExceptionHandler());
|
||||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
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 {
|
try {
|
||||||
// Robolectric calls onCreate for every test, which causes problems with static members
|
// Robolectric calls onCreate for every test, which causes problems with static members
|
||||||
EventBus.builder()
|
EventBus.builder()
|
||||||
|
|||||||
Reference in New Issue
Block a user