From ad1cbeb7bc8866b0572a791598226ce13a848d06 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 3 May 2024 17:08:23 +0530 Subject: [PATCH] Deleting the test application before running the test cases. --- contrib/instrumentation.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/contrib/instrumentation.sh b/contrib/instrumentation.sh index df4bacbdc..f63750893 100644 --- a/contrib/instrumentation.sh +++ b/contrib/instrumentation.sh @@ -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