test/widget_test.dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:chapter_04/main.dart';
// リスト 7.7
Widget _createCountPage() => MaterialApp(home: CountPage());
void main() {
testWidgets('Count Page Widget Tests', (WidgetTester tester) async {
await tester.pumpWidget(_createCountPage());
expect(find.text('カウント'), findsOneWidget);
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
expect(find.text('1'), findsOneWidget);
await tester.tap(find.byIcon(Icons.remove));
await tester.pump();
expect(find.text('0'), findsOneWidget);
});
}