Skip to content

enha: Flutter min version test #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b40d314
add dvice test running sentry setup and checking wether ui has loaded
denrase Oct 10, 2022
fcc40f7
add github action for integration tests
denrase Oct 10, 2022
078c83c
build debug apk
denrase Oct 10, 2022
c7db8b6
build debug apk and run integratin test on enumlator
denrase Oct 10, 2022
afaf307
don’t build apk before
denrase Oct 10, 2022
8df868c
fix name
denrase Oct 10, 2022
6414522
run parent dir test
denrase Oct 10, 2022
f385cf9
build apk through flutter and only run flutter test in emulator step
denrase Oct 10, 2022
c835a9c
verify directory content
denrase Oct 10, 2022
d3789e3
fix typo
denrase Oct 10, 2022
9812c18
provide working dir to android emulator step
denrase Oct 10, 2022
f00bb4d
no need to build apk beforehand
denrase Oct 10, 2022
74d74f7
no need toshow dir content
denrase Oct 10, 2022
9862ee6
run on ios simulator
denrase Oct 10, 2022
cbbc477
run on smallest supported ios version for action
denrase Oct 10, 2022
9e971fb
enable android test
denrase Oct 10, 2022
6c95df8
run ios 14 simulator, run on flutter beta
denrase Oct 11, 2022
11a1490
bump sim version to lowest supported by action
denrase Oct 11, 2022
14171b1
run on version that works
denrase Oct 11, 2022
97046d6
specify device
denrase Oct 11, 2022
8d3ca56
revert versions again
denrase Oct 11, 2022
23b6675
fix input
denrase Oct 11, 2022
1b225d9
bump vesion
denrase Oct 11, 2022
43b27cd
fix order
denrase Oct 11, 2022
73e2483
pin action steps
denrase Oct 11, 2022
e258802
Merge branch 'main' into enha/flutter-min-version-test
denrase Oct 11, 2022
e4da556
run format
denrase Oct 11, 2022
44ebf16
pin third party actions and add version comments
denrase Oct 17, 2022
8656247
Merge branch 'main' into enha/flutter-min-version-test
denrase Oct 17, 2022
844f08b
run android on ubuntu, split workflow in 2 jobs
denrase Oct 17, 2022
37f7bf2
rename test and run all native bridge commands
denrase Oct 17, 2022
399b8a9
Merge branch 'main' into enha/flutter-min-version-test
denrase Oct 17, 2022
3e4f9b7
remove not needed async
denrase Oct 17, 2022
3aaa295
Merge branch 'main' into enha/flutter-min-version-test
denrase Oct 24, 2022
c028b3e
test sentry public api
denrase Oct 24, 2022
893961e
Merge branch 'main' into enha/flutter-min-version-test
denrase Oct 25, 2022
9efd563
Merge branch 'main' into enha/flutter-min-version-test
denrase Nov 7, 2022
33af637
fix test expectation
denrase Nov 7, 2022
efb44c3
Merge branch 'main' into enha/flutter-min-version-test
denrase Nov 14, 2022
bdf60af
Merge branch 'main' into enha/flutter-min-version-test
denrase Nov 14, 2022
d7d9aa9
update where tests are run
denrase Nov 14, 2022
2a0f5d4
run format
denrase Nov 14, 2022
5158fc5
remove unused imports
denrase Nov 14, 2022
c49118c
also pass stacktrace
denrase Nov 14, 2022
398258a
reset user
denrase Nov 15, 2022
5f4fa4d
add screenshot widget
denrase Nov 15, 2022
cac4064
start/finish transactions
denrase Nov 15, 2022
d81fddf
run format
denrase Nov 15, 2022
ebadd79
cancel previous workflow
denrase Nov 15, 2022
180ec29
Merge branch 'main' into enha/flutter-min-version-test
marandaneto Nov 15, 2022
0177b6b
Merge branch 'main' into enha/flutter-min-version-test
marandaneto Nov 17, 2022
7456af5
Merge branch 'main' into enha/flutter-min-version-test
marandaneto Nov 18, 2022
893b3bb
Merge branch 'main' into enha/flutter-min-version-test
marandaneto Nov 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/flutter_integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: flutter integration tests
on:
push:
branches:
- main
pull_request:

jobs:
test-android:
runs-on: macos-latest
defaults:
run:
working-directory: ./flutter/example
strategy:
matrix:
sdk: ['stable', 'beta']
steps:
- name: checkout
uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'

- uses: subosito/flutter-action@1e6ee87cb840500837bcd50a667fb28815d8e310 # pin@v2
with:
channel: ${{ matrix.sdk }}

- name: flutter upgrade
run: flutter upgrade

- name: flutter pub get
run: flutter pub get

- name: launch android emulator & run android integration test
uses: reactivecircus/android-emulator-runner@d7b53ddc6e44254e1f4cf4a6ad67345837027a66 #[email protected]
with:
working-directory: ./flutter/example
api-level: 21
arch: x86_64
profile: Nexus 6
script: flutter test integration_test/integration_test.dart
test-ios:
runs-on: macos-11
defaults:
run:
working-directory: ./flutter/example
strategy:
matrix:
sdk: ['stable', 'beta']
steps:
- name: checkout
uses: actions/checkout@v3

- uses: subosito/flutter-action@1e6ee87cb840500837bcd50a667fb28815d8e310 # pin@v2
with:
channel: ${{ matrix.sdk }}

- name: flutter upgrade
run: flutter upgrade

- name: flutter pub get
run: flutter pub get

- name: launch ios emulator
uses: futureware-tech/simulator-action@ee05c113b79f056b47f354d7b313555f5491e158 #pin@v2
with:
model: 'iPhone 8'
os_version: '15.2'

- name: run ios integration test
run: flutter test integration_test/integration_test.dart
106 changes: 106 additions & 0 deletions flutter/example/integration_test/integration_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_flutter_example/main.dart';

void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;

Future<void> setupSentryAndApp(WidgetTester tester) async {
await setupSentry(() async {
await tester.pumpWidget(DefaultAssetBundle(
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
child: MyApp(),
));
await tester.pumpAndSettle();
});
}

// Tests

testWidgets('setup sentry and render app', (tester) async {
await setupSentryAndApp(tester);

// Find any UI element and verify it is present.
expect(find.text('Open another Scaffold'), findsOneWidget);
});

testWidgets('setup sentry and capture event', (tester) async {
await setupSentryAndApp(tester);

final event = SentryEvent();
final sentryId = await Sentry.captureEvent(event);

expect(sentryId != SentryId.empty(), true);
});

testWidgets('setup sentry and capture exception', (tester) async {
await setupSentryAndApp(tester);

try {
throw SentryException(
type: 'StarError', value: 'I have a bad feeling about this...');
} catch (exception, stacktrace) {
final sentryId =
await Sentry.captureException(exception, stackTrace: stacktrace);

expect(sentryId != SentryId.empty(), true);
}
});

testWidgets('setup sentry and capture message', (tester) async {
await setupSentryAndApp(tester);

final sentryId = await Sentry.captureMessage('hello world!');

expect(sentryId != SentryId.empty(), true);
});

testWidgets('setup sentry and capture user feedback', (tester) async {
await setupSentryAndApp(tester);

final feedback = SentryUserFeedback(
eventId: SentryId.newId(),
name: 'fixture-name',
email: '[email protected]',
comments: 'fixture-comments');
await Sentry.captureUserFeedback(feedback);
});

testWidgets('setup sentry and close', (tester) async {
await setupSentryAndApp(tester);

await Sentry.close();
});

testWidgets('setup sentry and add breadcrumb', (tester) async {
await setupSentryAndApp(tester);

final breadcrumb = Breadcrumb(message: 'fixture-message');
await Sentry.addBreadcrumb(breadcrumb);
});

testWidgets('setup sentry and configure scope', (tester) async {
await setupSentryAndApp(tester);

await Sentry.configureScope((scope) async {
await scope.setContexts('contexts-key', 'contexts-value');
await scope.removeContexts('contexts-key');

final user = SentryUser(id: 'fixture-id');
await scope.setUser(user);

final breadcrumb = Breadcrumb(message: 'fixture-message');
await scope.addBreadcrumb(breadcrumb);
await scope.clearBreadcrumbs();

await scope.setExtra('extra-key', 'extra-value');
await scope.removeExtra('extra-key');

await scope.setTag('tag-key', 'tag-value');
await scope.removeTag('tag-key');
});
});
}
52 changes: 27 additions & 25 deletions flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,34 @@ const String _exampleDsn =
final _channel = const MethodChannel('example.flutter.sentry.io');

Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = _exampleDsn;
options.tracesSampleRate = 1.0;
options.reportPackages = false;
options.addInAppInclude('sentry_flutter_example');
options.considerInAppFramesByDefault = false;
options.attachThreads = true;
options.enableWindowMetricBreadcrumbs = true;
options.addIntegration(LoggingIntegration());
options.attachScreenshot = true;
// We can enable Sentry debug logging during development. This is likely
// going to log too much for your app, but can be useful when figuring out
// configuration issues, e.g. finding out why your events are not uploaded.
options.debug = true;
},
// Init your App.
appRunner: () => runApp(
SentryScreenshotWidget(
child: DefaultAssetBundle(
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
child: MyApp(),
await setupSentry(() => runApp(
SentryScreenshotWidget(
child: DefaultAssetBundle(
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
child: MyApp(),
),
),
),
),
);
));
}

Future<void> setupSentry(AppRunner appRunner) async {
await SentryFlutter.init((options) {
options.dsn = _exampleDsn;
options.tracesSampleRate = 1.0;
options.reportPackages = false;
options.addInAppInclude('sentry_flutter_example');
options.considerInAppFramesByDefault = false;
options.attachThreads = true;
options.enableWindowMetricBreadcrumbs = true;
options.addIntegration(LoggingIntegration());
options.attachScreenshot = true;
// We can enable Sentry debug logging during development. This is likely
// going to log too much for your app, but can be useful when figuring out
// configuration issues, e.g. finding out why your events are not uploaded.
options.debug = true;
},
// Init your App.
appRunner: appRunner);
}

class MyApp extends StatefulWidget {
Expand Down
4 changes: 4 additions & 0 deletions flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ dependencies:
dev_dependencies:
pedantic: ^1.11.1
sentry_dart_plugin: ^1.0.0-beta.1
integration_test:
sdk: flutter
flutter_test:
sdk: flutter

flutter:
uses-material-design: true
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/src/sentry_native_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SentryNativeChannel {

Future<void> beginNativeFrames() async {
try {
await _channel.invokeMapMethod<String, dynamic>('beginNativeFrames');
await _channel.invokeMethod('beginNativeFrames');
} catch (error, stackTrace) {
_logError('beginNativeFrames', error, stackTrace);
}
Expand Down
3 changes: 1 addition & 2 deletions flutter/test/sentry_native_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ void main() {
final sut = fixture.getSut();
await sut.beginNativeFrames();

verify(fixture.methodChannel
.invokeMapMethod<String, dynamic>('beginNativeFrames'));
verify(fixture.methodChannel.invokeMethod('beginNativeFrames'));
});

test('endNativeFrames', () async {
Expand Down