29 lines
890 B
Dart
29 lines
890 B
Dart
// 这是一个基础的 Flutter 组件测试示例。
|
|
//
|
|
// 你可以通过 `WidgetTester` 与组件交互,例如点击、滚动,
|
|
// 也可以查找组件文本并验证组件属性是否符合预期。
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:quanxue/main.dart';
|
|
|
|
void main() {
|
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
|
// 构建应用并触发首帧渲染。
|
|
await tester.pumpWidget(const MyApp());
|
|
|
|
// 验证计数器初始值为 0。
|
|
expect(find.text('0'), findsOneWidget);
|
|
expect(find.text('1'), findsNothing);
|
|
|
|
// 点击加号按钮并重新渲染。
|
|
await tester.tap(find.byIcon(Icons.add));
|
|
await tester.pump();
|
|
|
|
// 验证计数器已经加 1。
|
|
expect(find.text('0'), findsNothing);
|
|
expect(find.text('1'), findsOneWidget);
|
|
});
|
|
}
|