android-emulator-runner icon indicating copy to clipboard operation
android-emulator-runner copied to clipboard

Instrumented Tests in Compose failing

Open igorescodro opened this issue 3 years ago • 6 comments

Hello, everyone!

I'm facing some issues since I ported my application to Jetpack Compose. Some of my tests are failing in the GitHub Action but are passing locally. The error are very simple one, like Reason: Expected exactly '1' node but could not find any node that satisfies, meaning that the Composable node was not found. However it does not fail on emulator locally (tried on Nexus 5, Pixel 4 XL and Generic).

Currently my script is:

name: instrumented tests

on: [ push ]

jobs:
  build:
    runs-on: macos-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Java
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'adopt'

      - name: Android Emulator Runner
        uses: ReactiveCircus/[email protected]
        with:
          api-level: 29
          target: google_apis
          script: ./gradlew connectedCheck --stacktrace

Am I missing some configuration to work better with Jetpack Compose?

Thanks a lot for your help!

igorescodro avatar Apr 23 '21 16:04 igorescodro

I haven't had time to try running compose tests with this action yet but I've seen similar issues as you mentioned in some compose-samples android tests which are ignored. However the accompanist library does run instrumentation tests with this action: https://github.com/google/accompanist/blob/main/.github/workflows/build.yml.

I'll look into it when I migrate my sample app to compose. But hopefully someone else can share their experience with running compose tests with this action😀

ychescale9 avatar Apr 23 '21 17:04 ychescale9

Thanks for the quick reply!

Feel free to use my open-source project to test, if you want. 😊 https://github.com/igorescodro/alkaa

I'll investigate this repo and try to test it again. I'll let you know if works!

EDIT: didn't work with same configs. ☹️

igorescodro avatar Apr 23 '21 18:04 igorescodro

@igorescodro did you ever figure this out? Having similar issues.. assertIsDisplayed() fails, but only on the GH Actions emulator. Running a local headless emulator and the tests pass.

timusus avatar Dec 29 '21 04:12 timusus

I am having the same exact issue. my fix, as dirty as it is, is working. I am adding Thread.sleep(2000) in between steps to give the emulator some room to be slow .. Also I used api 28 , seem to have better results overall on it!

jrdaher avatar Mar 16 '22 19:03 jrdaher

I am back to having failures, it seems waitUntil fails on the CI everytime but never locally. I am not able to get more insights..

jrdaher avatar Sep 07 '22 16:09 jrdaher

can this thread get some love ? thanks :)

jrdaher avatar Oct 11 '22 13:10 jrdaher

@jrdaher Sorry, my theory is this is because the emulators are really slow on CI with the Standard Github Runners. Unfortunately it seems like this issue is more related to the AndroidX.Test team, Google Emulator team, Github Runner team -- and the mix of those, rather than this action itself.

mrk-han avatar Nov 02 '22 04:11 mrk-han

I'm having this same issue, has someone managed to fix it?

ArnyminerZ avatar Apr 20 '23 11:04 ArnyminerZ