diff --git a/README.md b/README.md index 5a18dee..bbbd7d0 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,26 @@ curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ `BrowserStack.init()` sets up the integration test binding, so call it before anything else in `main()`. If your tests call `IntegrationTestWidgetsFlutterBinding.ensureInitialized()`, remove that line or move it after `BrowserStack.init()`. If the binding is created first, fewer actions get an accessibility scan. + If you run several test files from one entry file, call `BrowserStack.init()` once at the top of the entry file's `main()`, before any `group()`: + + ```dart + // integration_test/all_tests.dart + import 'package:browserstack_dart_sdk/browserstack_dart_sdk.dart'; + import 'package:flutter_test/flutter_test.dart'; + + import 'login_test.dart' as login; + import 'checkout_test.dart' as checkout; + + void main() { + BrowserStack.init(); + + group('login', login.main); + group('checkout', checkout.main); + } + ``` + + Then build with `-t integration_test/all_tests.dart`. The `BrowserStack.init()` calls inside `login_test.dart` and `checkout_test.dart` can stay: after the first call, later calls do nothing. If `init()` only runs inside a `group()`, only that group's tests are reported, and the device log warns about it. + 3. Make sure your app has the native test runners that `integration_test` needs on BrowserStack, as in this repo: - Android: an instrumentation test like `MainActivityTest.java`, and `testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"` in `android/app/build.gradle.kts`. - iOS: a `RunnerTests` target with `RunnerTests.m`. @@ -198,8 +218,9 @@ Tags are the standard Dart test tags: `testWidgets('...', (tester) async { ... } ## Good to know - iOS builds for BrowserStack are release builds, and in release builds `integration_test` doesn't pass `enterText` to your app. Call `tester.testTextInput.register()` at the start of tests that type text, as `integration_test/app_test.dart` does. +- On Flutter 3.27 to 3.40, keep Swift Package Manager off for the iOS build. It's off by default on these versions; if you turned it on, the iOS build can fail because the package's Swift package needs Flutter's `FlutterFramework` package, which Flutter adds in 3.41. Turn it off with `flutter config --no-enable-swift-package-manager`. Other Flutter versions aren't affected. - Requests your app makes with Dart's own `HttpClient` don't go through the device's proxy. They won't show in network logs, and they can't reach [BrowserStack Local](https://www.browserstack.com/docs/app-automate/flutter/get-started-with-local-testing) unless your app sets the proxy itself. This doesn't affect Test Reporting or App Accessibility. -- The package logs what it does with the prefix `[BrowserStack]`. On Android these lines are in the device logs, which App Automate keeps when the build request has `"deviceLogs": true`. On iOS they are in each test's instrumentation log. If you contact BrowserStack support about a run, they may ask for these logs. +- The package logs what it does with the prefix `[BROWSERSTACK_SDK]`. On Android these lines are in the device logs, which App Automate keeps when the build request has `"deviceLogs": true`. On iOS they are in each test's instrumentation log. If you contact BrowserStack support about a run, they may ask for these logs. ## Help