Skip to content

Commit

Permalink
dont use catch for test verification
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Jan 9, 2023
1 parent cc7cf83 commit 50bb8f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
15 changes: 9 additions & 6 deletions flutter/test/sentry_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void main() {
);

testScopeObserver(
options: sentryFlutterOptions!, hasNativeScopeObserver: true);
options: sentryFlutterOptions!, expectedHasNativeScopeObserver: true);

testConfiguration(
integrations: integrations,
Expand Down Expand Up @@ -124,7 +124,7 @@ void main() {
);

testScopeObserver(
options: sentryFlutterOptions!, hasNativeScopeObserver: true);
options: sentryFlutterOptions!, expectedHasNativeScopeObserver: true);

testConfiguration(
integrations: integrations,
Expand Down Expand Up @@ -170,7 +170,7 @@ void main() {
);

testScopeObserver(
options: sentryFlutterOptions!, hasNativeScopeObserver: true);
options: sentryFlutterOptions!, expectedHasNativeScopeObserver: true);

testConfiguration(
integrations: integrations,
Expand Down Expand Up @@ -216,7 +216,8 @@ void main() {
);

testScopeObserver(
options: sentryFlutterOptions!, hasNativeScopeObserver: false);
options: sentryFlutterOptions!,
expectedHasNativeScopeObserver: false);

testConfiguration(
integrations: integrations,
Expand Down Expand Up @@ -264,7 +265,8 @@ void main() {
);

testScopeObserver(
options: sentryFlutterOptions!, hasNativeScopeObserver: false);
options: sentryFlutterOptions!,
expectedHasNativeScopeObserver: false);

testConfiguration(
integrations: integrations,
Expand Down Expand Up @@ -315,7 +317,8 @@ void main() {
);

testScopeObserver(
options: sentryFlutterOptions!, hasNativeScopeObserver: false);
options: sentryFlutterOptions!,
expectedHasNativeScopeObserver: false);

testConfiguration(
integrations: integrations,
Expand Down
15 changes: 8 additions & 7 deletions flutter/test/sentry_flutter_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ void testTransport({

void testScopeObserver(
{required SentryFlutterOptions options,
required bool hasNativeScopeObserver}) {
try {
options.scopeObservers
.firstWhere((element) => element.runtimeType == NativeScopeObserver);
expect(true, hasNativeScopeObserver);
} catch (_) {
expect(false, hasNativeScopeObserver);
required bool expectedHasNativeScopeObserver}) {
var actualHasNativeScopeObserver = false;
for (final scopeObserver in options.scopeObservers) {
if (scopeObserver.runtimeType == NativeScopeObserver) {
actualHasNativeScopeObserver = true;
break;
}
}
expect(actualHasNativeScopeObserver, expectedHasNativeScopeObserver);
}

void testConfiguration({
Expand Down

0 comments on commit 50bb8f1

Please sign in to comment.