diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 15d2921a7..94155e7c3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,11 +14,10 @@ jobs: coverageReport: strategy: - max-parallel: 2 matrix: - api-level: [21, 30, 21,30] + api-level: [21,30] fail-fast: false - runs-on: macOS-latest + runs-on: macos-10.15 steps: - name: checkout uses: actions/checkout@v3 @@ -27,12 +26,15 @@ jobs: - name: create instrumentation coverage uses: ReactiveCircus/android-emulator-runner@v2.23.0 + env: + GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000" with: api-level: ${{ matrix.api-level }} arch: x86_64 ndk: 21.4.7075529 script: bash contrib/instrumentation.sh + - name: Upload screenshot result uses: actions/upload-artifact@v1 if: failure() @@ -41,15 +43,17 @@ jobs: path: screencap.png - name: create unit coverage + if: ${{ matrix.api-level==21 }} run: ./gradlew jacocoTestDebugUnitTestReport jacocoTestCustomExampleDebugUnitTestReport - name: Upload coverage to Codecov + if: ${{ matrix.api-level==21 }} run: | bash <(curl -s https://codecov.io/bash) - name: Upload Coverage to GH-Actions uses: actions/upload-artifact@v2.2.0 - if: ${{ always() }} + if: ${{ matrix.api-level==21 }} with: name: Tests Coverage Report path: | diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt index 81c8a5f25..9e387921f 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt @@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile import android.R.id import android.app.Instrumentation import android.content.Context +import androidx.test.espresso.NoMatchingViewException import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.Direction import androidx.test.uiautomator.UiDevice @@ -81,9 +82,20 @@ abstract class BaseRobot( private fun waitFor( findable: Findable, - timeout: Long = VERY_LONG_WAIT - ): UiObject2? = - uiDevice.wait(Until.findObject(findable.selector(this)), timeout) + timeout: Long = VERY_LONG_WAIT, + retryCount: Int = 5 + ): UiObject2? { + var uiObject2: UiObject2? = null + for (i in 0 until retryCount) { + try { + uiObject2 = uiDevice.wait(Until.findObject(findable.selector(this)), timeout) + break + } catch (noMatchingViewException: NoMatchingViewException) { + noMatchingViewException.printStackTrace() + } + } + return uiObject2 + } private fun UiObject2.customSwipe( direction: Direction, diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt index 09a387338..1af04c0c2 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt @@ -34,13 +34,10 @@ class IntroRobot : BaseRobot() { private val getStarted = ViewId(R.id.get_started) private val viewPager = ViewId(R.id.view_pager) - init { + fun swipeLeft() { isVisible(getStarted) isVisible(TextId(R.string.welcome_to_the_family)) isVisible(TextId(R.string.humankind_knowledge)) - } - - fun swipeLeft() { attempt(10) { isVisible(viewPager).swipeLeft() isVisible(TextId(R.string.save_books_offline)) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt index 6a00fb3bd..e75074883 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt @@ -17,8 +17,8 @@ */ package org.kiwix.kiwixmobile.main -import com.adevinta.android.barista.interaction.BaristaSleepInteractions import applyWithViewHierarchyPrinting +import com.adevinta.android.barista.interaction.BaristaSleepInteractions import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable.StringId.TextId import org.kiwix.kiwixmobile.Findable.ViewId @@ -47,11 +47,8 @@ fun topLevel(func: TopLevelDestinationRobot.() -> Unit) = class TopLevelDestinationRobot : BaseRobot() { - init { - isVisible(ViewId(R.id.navigation_container)) - } - fun clickReaderOnBottomNav(func: ReaderRobot.() -> Unit) { + isVisible(ViewId(R.id.navigation_container)) BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) clickOn(ViewId(R.id.readerFragment)) reader(func)