Created
June 7, 2025 03:52
-
-
Save rubywai/368f03ddac73236253a4caea3bed1528 to your computer and use it in GitHub Desktop.
This file contains hidden or 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_test/flutter_test.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:untitled/main.dart'; | |
void main() { | |
testWidgets('App loads and shows counter UI', (WidgetTester tester) async { | |
// Run the full app (includes main(), MyApp, Home) | |
await tester.pumpWidget(const MyApp()); | |
// Ensure title is present | |
expect(find.text('Counter app with bloc pattern'), findsOneWidget); | |
// Check initial state | |
expect(find.text('The counter is 0'), findsOneWidget); | |
// Tap Increment and test | |
await tester.tap(find.text('Increment')); | |
await tester.pump(); | |
expect(find.text('The counter is 1'), findsOneWidget); | |
// Tap Reset | |
await tester.tap(find.text('Reset')); | |
await tester.pump(); | |
expect(find.text('The counter is 0'), findsOneWidget); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment