Created
November 22, 2022 22:12
-
-
Save antonkrasov/3b0bef6c761abc4b98263d03146201d5 to your computer and use it in GitHub Desktop.
Integration test file for Flutter Automation tutorial
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
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:integration_test/integration_test.dart'; | |
import 'package:taskezdev/main.dart' as app; | |
import 'package:taskezdev/main.dart'; | |
import 'helpers.dart'; | |
void main() { | |
const deviceName = String.fromEnvironment('DEVICE_NAME'); | |
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | |
group('end-to-end test', () { | |
testWidgets('onboarding UI test', (tester) async { | |
app.main(); | |
await tester.pumpAndSettle(); | |
await binding.convertFlutterSurfaceToImage(); | |
await precacheImage( | |
const AssetImage('assets/art_onboarding_1.png'), | |
tester.element( | |
find.byType(MyApp), | |
), | |
); | |
await tester.pumpAndSettle(); | |
await binding.delayed(const Duration(seconds: 1)); | |
await tester.pumpAndSettle(); | |
await binding.takeScreenshot('$deviceName/$deviceName-1'); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.text('Get Started'), | |
screenshotName: '$deviceName/$deviceName-2', | |
); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.text('Continue with Email'), | |
screenshotName: '$deviceName/$deviceName-3', | |
); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.text('Continue with Email'), | |
screenshotName: '$deviceName/$deviceName-4', | |
); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.widgetWithText(ElevatedButton, 'Sign Up'), | |
screenshotName: '$deviceName/$deviceName-5', | |
); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.text('Next'), | |
screenshotName: '$deviceName/$deviceName-6', | |
); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.text('Done'), | |
screenshotName: '$deviceName/$deviceName-7', | |
); | |
await tapAndTakeScreenshot( | |
binding, | |
tester, | |
find.image(const AssetImage('assets/avatar.png')), | |
screenshotName: '$deviceName/$deviceName-8', | |
); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment