Skip to content

Commit 0868ea1

Browse files
authored
Merge 43b27cd into 6d317ea
2 parents 6d317ea + 43b27cd commit 0868ea1

File tree

4 files changed

+98
-7
lines changed

4 files changed

+98
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: flutter integration tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: macos-latest
11+
defaults:
12+
run:
13+
working-directory: ./flutter/example
14+
strategy:
15+
matrix:
16+
sdk: ['stable', 'beta']
17+
steps:
18+
- name: checkout
19+
uses: actions/checkout@v3
20+
21+
- uses: actions/setup-java@v3
22+
with:
23+
distribution: 'adopt'
24+
java-version: '8'
25+
26+
- uses: subosito/flutter-action@v2
27+
with:
28+
channel: ${{ matrix.sdk }}
29+
30+
- name: flutter upgrade
31+
run: flutter upgrade
32+
33+
- name: flutter pub get
34+
run: flutter pub get
35+
36+
- name: launch android emulator & run android integration test
37+
uses: reactivecircus/android-emulator-runner@v2
38+
with:
39+
working-directory: ./flutter/example
40+
api-level: 21
41+
arch: x86_64
42+
profile: Nexus 6
43+
script: flutter test integration_test/launch_test.dart
44+
45+
- name: launch ios emulator
46+
uses: futureware-tech/simulator-action@v1
47+
with:
48+
model: 'iPhone 8'
49+
os_version: '15.2'
50+
51+
- name: run ios integration test
52+
run: flutter test integration_test/launch_test.dart
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:flutter/widgets.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:integration_test/integration_test.dart';
4+
import 'package:sentry_flutter/sentry_flutter.dart';
5+
import 'package:sentry_flutter_example/main.dart';
6+
7+
void main() {
8+
9+
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
11+
12+
testWidgets('setup sentry and render app', (tester) async {
13+
14+
await setupSentry(
15+
() async {
16+
await tester.pumpWidget(
17+
DefaultAssetBundle(
18+
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
19+
child: MyApp(),
20+
)
21+
);
22+
await tester.pumpAndSettle();
23+
}
24+
);
25+
26+
// Find any UI element and verify it is present.
27+
expect(find.text('Open another Scaffold'), findsOneWidget);
28+
});
29+
}

flutter/example/lib/main.dart

+13-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@ const String _exampleDsn =
2121
final _channel = const MethodChannel('example.flutter.sentry.io');
2222

2323
Future<void> main() async {
24+
await setupSentry(
25+
() => runApp(
26+
DefaultAssetBundle(
27+
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
28+
child: MyApp(),
29+
),
30+
)
31+
);
32+
}
33+
34+
Future<void> setupSentry(AppRunner appRunner) async {
2435
await SentryFlutter.init(
25-
(options) {
36+
(options) async {
2637
options.dsn = _exampleDsn;
2738
options.tracesSampleRate = 1.0;
2839
options.reportPackages = false;
@@ -37,12 +48,7 @@ Future<void> main() async {
3748
options.debug = true;
3849
},
3950
// Init your App.
40-
appRunner: () => runApp(
41-
DefaultAssetBundle(
42-
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
43-
child: MyApp(),
44-
),
45-
),
51+
appRunner: appRunner,
4652
);
4753
}
4854

flutter/example/pubspec.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ dependencies:
2424
dev_dependencies:
2525
pedantic: ^1.11.1
2626
sentry_dart_plugin: ^1.0.0-alpha.4
27+
integration_test:
28+
sdk: flutter
29+
flutter_test:
30+
sdk: flutter
2731

2832
dependency_overrides:
2933
sentry:

0 commit comments

Comments
 (0)