Last active
August 19, 2022 08:05
-
-
Save vinceramcesoliveros/346d6e8a9bbc0b854608f0c5c41c6b1c to your computer and use it in GitHub Desktop.
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:counter_app/main.dart' as app; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:integration_test/integration_test.dart'; | |
abstract class MyCounter {} | |
void main() { | |
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | |
group("Increment group", () { | |
testWidgets('Counter increments integration test', | |
(WidgetTester tester) async { | |
app.main(); | |
await tester.pumpAndSettle(); | |
// Verify that our counter starts at 0. | |
expect(find.text('0'), findsOneWidget); | |
expect(find.text('1'), findsNothing); | |
await Future.delayed(const Duration(seconds: 3)); | |
// Tap the '+' icon and trigger a frame. | |
await tester.tap(find.byTooltip('Increment')); | |
await tester.pumpAndSettle(); | |
await Future.delayed(const Duration(seconds: 2)); | |
// Verify that our counter has incremented. | |
expect(find.text('0'), findsNothing); | |
expect(find.text('1'), findsOneWidget); | |
await tester.tap(find.byTooltip('Increment')); | |
await Future.delayed(const Duration(seconds: 2)); | |
await tester.tap(find.byTooltip('Increment')); | |
await tester.tap(find.byTooltip('Increment')); | |
await tester.tap(find.byTooltip('Increment')); | |
expect(find.byIcon(Icons.fire_extinguisher), findsOneWidget); | |
await Future.delayed(const Duration(seconds: 5)); | |
}); | |
testWidgets("Enter flutter app in textfield", (WidgetTester tester) async { | |
app.main(); | |
await tester.pumpAndSettle(); | |
await tester.enterText(find.byKey(const Key('textfield')), 'flutter app'); | |
await tester.pumpAndSettle(); | |
expect(find.text('flutter app'), findsOneWidget); | |
await Future.delayed(const Duration(seconds: 5)); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment