Skip to content

Instantly share code, notes, and snippets.

@rubywai
Created June 7, 2025 03:52
Show Gist options
  • Save rubywai/368f03ddac73236253a4caea3bed1528 to your computer and use it in GitHub Desktop.
Save rubywai/368f03ddac73236253a4caea3bed1528 to your computer and use it in GitHub Desktop.
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