leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
883 stars 133 forks source link

Patrol test fails when using workmanager plugin #2370

Open ashwin-dailype opened 6 days ago

ashwin-dailype commented 6 days ago

Steps to reproduce

Problem

I have been using workmanager plugin in my private flutter app for a while now. I wrote a patrol test few months ago and it used to work fine. I stopped using patrol tests until today. Trying it again today started to give me the below error

Users/ashwin/Developer/dailype/android/app/src/androidTest/java/io/flutter/plugins/GeneratedPluginRegistrant.java:234: error: package be.tramckrijte.workmanager does not exist flutterEngine.getPlugins().add(new be.tramckrijte.workmanager.WorkmanagerPlugin());

I tried reproducing the problem in a separate project, however I'm getting a different error. The steps to reproduce it the way I did it are given below:

Steps to Reproduce

  1. Clone this repo: https://github.com/ashwin-dailype/patrol-error-mre
  2. Use Flutter 3.19.6 and Dart 3.3.4
  3. Activate patrol cli 3.0.1

Actual results

The example test from patrol docs fail with this error

Users/ashwin/Developer/dailype/android/app/src/androidTest/java/io/flutter/plugins/GeneratedPluginRegistrant.java:234: error: package be.tramckrijte.workmanager does not exist flutterEngine.getPlugins().add(new be.tramckrijte.workmanager.WorkmanagerPlugin());

Logs

patrol_error.txt

Patrol version

patrol: ^3.6.1

Patrol Doctor output

Patrol Doctor output ``` Patrol doctor: Patrol CLI version: 3.0.1 Flutter command: flutter Flutter 3.19.6 • channel stable Android: • Program adb found in /Users/ashwin/Library/Android/sdk/platform-tools/adb • Env var $ANDROID_HOME set to /Users/ashwin/Library/Android/sdk iOS / macOS: • Program xcodebuild found in /usr/bin/xcodebuild```

Flutter Doctor output

Flutter Doctor output ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.19.6, on macOS 15.0.1 24A348 darwin-arm64, locale en-IN) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.2) [✓] VS Code (version 1.94.2) [✓] Connected device (3 available) [✓] Network resources • No issues found! ```
Kendru98 commented 6 days ago

Hi @ashwin-dailype we are glad that you use patrol! I was able to clone your repository. First I tried to reproduce it with yours patrol and flutter versions, but something was buggy on old versions for me. I updated:

Then I execute patrol test -v on android emulator with API 33. And all works fine. Are you able to update these things in your project? You can also try to clean some cache in your repository:

cd ./android && ./gradlew :clean && ./gradlew --stop && cd ..
rm -rf ./build
rm -rf ~/.gradle/caches
flutter clean

and optionally:

[!CAUTION] dart pub cache clean # this command remove pub packages and you'll need to install them manually