leancodepl / patrol

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

Patrol CLI doesn't work when the iOS workspace is not named `Runner` #1878

Open ne3Vubeki opened 12 months ago

ne3Vubeki commented 12 months ago

Steps to reproduce

  1. Change the name Runner of any project on iOS
  2. Run any patrol test

Actual results

My flutter project has a different name from Runner. I just started using patrol and encountered an error when starting testing on iOS.

Logs

Logs ``` Verbose mode enabled. More logs will be printed. Received 1 test target(s) Received test target: /Users/***/integration_test/app_test.dart Generated entrypoint /Users/***/integration_test/test_bundle.dart with 1 bundled test(s) $ flutter --no-version-check devices --machine No device specified, using the first one (iPhone 12 mini) Received 1 device(s) to run on Received device: iPhone 12 mini Received 7 --dart-define(s) (0 custom, 7 internal) Received internal --dart-define: PATROL_WAIT=0 Received internal --dart-define: PATROL_APP_PACKAGE_NAME=*** Received internal --dart-define: PATROL_APP_BUNDLE_ID=*** Received internal --dart-define: PATROL_ANDROID_APP_NAME=*** Received internal --dart-define: PATROL_IOS_APP_NAME=*** Received internal --dart-define: INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false Received internal --dart-define: PATROL_TEST_LABEL_ENABLED=true • Building app with entrypoint test_bundle.dart for iOS simulator (debug)... $ flutter build ios --no-version-check --config-only --no-codesign --debug --simulator --target /Users/***/integration_test/test_bundle.dart --dart-define PATROL_WAIT=0 --dart-define PATROL_APP_PACKAGE_NAME=*** --dart-define PATROL_APP_BUNDLE_ID=*** --dart-define PATROL_ANDROID_APP_NAME=*** --dart-define PATROL_IOS_APP_NAME=*** --dart-define INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false --dart-define PATROL_TEST_LABEL_ENABLED=true Building *** for simulator (ios)... $ xcodebuild build-for-testing -workspace Runner.xcworkspace -scheme Runner -configuration Debug -only-testing RunnerUITests -sdk iphonesimulator -destination generic/platform=iOS Simulator -quiet -derivedDataPath ../build/ios_integ OTHER_SWIFT_FLAGS=$(inherited) -D PATROL_ENABLED 2023-11-07 17:59:05.364 xcodebuild[28377:23327307] Writing error result bundle to /var/folders/sk/dfb7wz7126vbvdzsbhwyyms00000gn/T/ResultBundle_2023-07-11_17-59-0005.xcresult xcodebuild: error: 'Runner.xcworkspace' does not exist. ✗ Failed to build app with entrypoint test_bundle.dart for iOS simulator (xcodebuild exited with code 66) (7.7s) Error: xcodebuild exited with code 66 #0 throwToolExit (package:patrol_cli/src/base/exceptions.dart:7:3) #1 IOSTestBackend.build. (package:patrol_cli/src/ios/ios_test_backend.dart:132:9) #2 DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7) #3 IOSTestBackend.build (package:patrol_cli/src/ios/ios_test_backend.dart:72:5) #4 TestCommand._build (package:patrol_cli/src/commands/test.dart:234:7) #5 TestCommand.run (package:patrol_cli/src/commands/test.dart:167:5) #6 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #7 PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:321:18) #8 PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:265:18) #9 patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:77:20) #10 main (file:///Users/freshbook/.pub-cache/hosted/pub.dev/patrol_cli-2.2.2/bin/main.dart:6:20) See the logs above to learn what happened. Also consider running with --verbose. If the logs still aren't useful, then it's a bug - please report it. Error: xcodebuild exited with code 66 #0 throwToolExit (package:patrol_cli/src/base/exceptions.dart:7:3) #1 IOSTestBackend.build. (package:patrol_cli/src/ios/ios_test_backend.dart:132:9) #2 DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7) #3 IOSTestBackend.build (package:patrol_cli/src/ios/ios_test_backend.dart:72:5) #4 TestCommand._build (package:patrol_cli/src/commands/test.dart:234:7) #5 TestCommand.run (package:patrol_cli/src/commands/test.dart:167:5) #6 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #7 PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:321:18) #8 PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:265:18) #9 patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:77:20) #10 main (file:///Users/freshbook/.pub-cache/hosted/pub.dev/patrol_cli-2.2.2/bin/main.dart:6:20) ```

Patrol version

patrol: ^2.3.2

Patrol Doctor output

Patrol Doctor output ``` Patrol CLI version: 2.2.2 Program adb found in /usr/local/bin/adb Env var $ANDROID_HOME set to /Users/freshbook/Library/Android/sdk Program xcodebuild found in /usr/bin/xcodebuild Program ideviceinstaller found in /usr/local/bin/ideviceinstaller ```

Flutter Doctor output

Flutter Doctor output ``` [✓] Flutter (Channel stable, 3.13.9, on macOS 14.0 23A344 darwin-arm64 (Rosetta), locale ru-RU) • Flutter version 3.13.9 on channel stable at /Users/freshbook/Library/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d211f42860 (2 недели назад), 2023-10-25 13:42:25 -0700 • Engine revision 0545f8705d • Dart version 3.1.5 • DevTools version 2.25.0 [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/freshbook/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#andro id-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.12.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.83.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.76.0 [✓] Connected device (3 available) • iPhone 12 mini (mobile) • 13F8003D-207D-438D-8B61-462D0D2456A5 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64 (Rosetta) • Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.105 [✓] Network resources • All expected network resources are available. ```
bartekpacia commented 12 months ago

Runner.xcworkspace is hardcoded in Patrol CLI:

https://github.com/leancodepl/patrol/blob/bcdad8ba4b4c2969fd4957e4ed8a8bfb2f0baccd/packages/patrol_cli/lib/src/crossplatform/app_options.dart#L170

Feel free to contribute a fix, or change your app to use Runner.

ne3Vubeki commented 12 months ago

It would be great to add the ability to use different project names