widget_test.dart 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // This is a basic Flutter widget test.
  2. //
  3. // To perform an interaction with a widget in your test, use the WidgetTester
  4. // utility that Flutter provides. For example, you can send tap and scroll
  5. // gestures. You can also use WidgetTester to find child widgets in the widget
  6. // tree, read text, and verify that the values of widget properties are correct.
  7. import 'package:flutter/material.dart';
  8. import 'package:flutter_test/flutter_test.dart';
  9. import 'package:flutter_tracker/main.dart';
  10. /// Description:
  11. /// Time : 2021年12月03日 Friday
  12. /// Author : liuyuqi.gov@msncn
  13. void main() {
  14. testWidgets('Counter increments smoke test', (WidgetTester tester) async {
  15. // Build our app and trigger a frame.
  16. await tester.pumpWidget(MyApp());
  17. // Verify that our counter starts at 0.
  18. expect(find.text('0'), findsOneWidget);
  19. expect(find.text('1'), findsNothing);
  20. // Tap the '+' icon and trigger a frame.
  21. await tester.tap(find.byIcon(Icons.add));
  22. await tester.pump();
  23. // Verify that our counter has incremented.
  24. expect(find.text('0'), findsNothing);
  25. expect(find.text('1'), findsOneWidget);
  26. });
  27. }