Skip to content

Commit e11ab22

Browse files
authored
Merge pull request #2 from browserstack/SDK-8262-swiftpm-note
SDK-8262: README notes for entry files and Swift Package Manager, fix the log prefix
2 parents 8edf9ff + 6e425be commit e11ab22

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,26 @@ curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
154154

155155
`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.
156156

157+
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()`:
158+
159+
```dart
160+
// integration_test/all_tests.dart
161+
import 'package:browserstack_dart_sdk/browserstack_dart_sdk.dart';
162+
import 'package:flutter_test/flutter_test.dart';
163+
164+
import 'login_test.dart' as login;
165+
import 'checkout_test.dart' as checkout;
166+
167+
void main() {
168+
BrowserStack.init();
169+
170+
group('login', login.main);
171+
group('checkout', checkout.main);
172+
}
173+
```
174+
175+
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.
176+
157177
3. Make sure your app has the native test runners that `integration_test` needs on BrowserStack, as in this repo:
158178
- Android: an instrumentation test like `MainActivityTest.java`, and `testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"` in `android/app/build.gradle.kts`.
159179
- iOS: a `RunnerTests` target with `RunnerTests.m`.
@@ -198,8 +218,9 @@ Tags are the standard Dart test tags: `testWidgets('...', (tester) async { ... }
198218
## Good to know
199219

200220
- 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.
221+
- 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.
201222
- 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.
202-
- 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.
223+
- 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.
203224

204225
## Help
205226

0 commit comments

Comments
 (0)