Deleting the test application before running the test cases.

This commit is contained in:
MohitMaliFtechiz 2024-05-03 17:08:23 +05:30
parent ff9c82ebb8
commit ad1cbeb7bc

View File

@ -7,15 +7,21 @@ adb logcat -c
adb logcat *:E -v color &
PACKAGE_NAME="org.kiwix.kiwixmobile"
TEST_PACKAGE_NAME="${PACKAGE_NAME}.test"
# Function to check if the application is installed
is_app_installed() {
adb shell pm list packages | grep -q "${PACKAGE_NAME}"
adb shell pm list packages | grep -q "$1"
}
if is_app_installed; then
if is_app_installed "$PACKAGE_NAME"; then
# Delete the application to properly run the test cases.
adb uninstall "${PACKAGE_NAME}"
fi
if is_app_installed "$TEST_PACKAGE_NAME"; then
# Delete the test application to properly run the test cases.
adb uninstall "${TEST_PACKAGE_NAME}"
fi
retry=0
while [ $retry -le 3 ]; do
if ./gradlew jacocoInstrumentationTestReport; then
@ -30,10 +36,14 @@ while [ $retry -le 3 ]; do
# shellcheck disable=SC2035
adb logcat *:E -v color &
if is_app_installed; then
if is_app_installed "$PACKAGE_NAME"; then
# Delete the application to properly run the test cases.
adb uninstall "${PACKAGE_NAME}"
fi
if is_app_installed "$TEST_PACKAGE_NAME"; then
# Delete the test application to properly run the test cases.
adb uninstall "${TEST_PACKAGE_NAME}"
fi
./gradlew clean
retry=$(( retry + 1 ))
if [ $retry -eq 3 ]; then