Skip to content

Commit f44f042

Browse files
authored
Merge e4da556 into 6d317ea
2 parents 6d317ea + e4da556 commit f44f042

File tree

4 files changed

+90
-7
lines changed

4 files changed

+90
-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@d7b53ddc6e44254e1f4cf4a6ad67345837027a66
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@3899fc55d5bf1b24285a746651728263187ce9f5
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,23 @@
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+
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
9+
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
10+
11+
testWidgets('setup sentry and render app', (tester) async {
12+
await setupSentry(() async {
13+
await tester.pumpWidget(DefaultAssetBundle(
14+
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
15+
child: MyApp(),
16+
));
17+
await tester.pumpAndSettle();
18+
});
19+
20+
// Find any UI element and verify it is present.
21+
expect(find.text('Open another Scaffold'), findsOneWidget);
22+
});
23+
}

flutter/example/lib/main.dart

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

2323
Future<void> main() async {
24+
await setupSentry(() => runApp(
25+
DefaultAssetBundle(
26+
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
27+
child: MyApp(),
28+
),
29+
));
30+
}
31+
32+
Future<void> setupSentry(AppRunner appRunner) async {
2433
await SentryFlutter.init(
25-
(options) {
34+
(options) async {
2635
options.dsn = _exampleDsn;
2736
options.tracesSampleRate = 1.0;
2837
options.reportPackages = false;
@@ -37,12 +46,7 @@ Future<void> main() async {
3746
options.debug = true;
3847
},
3948
// Init your App.
40-
appRunner: () => runApp(
41-
DefaultAssetBundle(
42-
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
43-
child: MyApp(),
44-
),
45-
),
49+
appRunner: appRunner,
4650
);
4751
}
4852

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)