-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enha: Flutter min version test (#1061)
- Loading branch information
Showing
6 changed files
with
238 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: flutter integration tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
cancel-previous-workflow: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # pin@0.11.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
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 #pin@v2.26.0 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
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(SentryScreenshotWidget( | ||
child: 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: 'fixture@email.com', | ||
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); | ||
await scope.setUser(null); | ||
|
||
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'); | ||
}); | ||
}); | ||
|
||
testWidgets('setup sentry and start transaction', (tester) async { | ||
await setupSentryAndApp(tester); | ||
|
||
final transaction = Sentry.startTransaction('transaction', 'test'); | ||
await transaction.finish(); | ||
}); | ||
|
||
testWidgets('setup sentry and start transaction with context', | ||
(tester) async { | ||
await setupSentryAndApp(tester); | ||
|
||
final context = SentryTransactionContext('transaction', 'test'); | ||
final transaction = Sentry.startTransactionWithContext(context); | ||
await transaction.finish(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters