Closed BinaryITSolution closed 1 year ago
You can achieve your requirement by using the "flutter_test" dependency. Please follow the steps below to meet your needs.
Before writing tests, include the flutter_test dependency in the dev_dependencies section of the pubspec.yaml file.
dev_dependencies: flutter_test: sdk: flutter
Refer to the below link for more details about widget testing in the Flutter https://docs.flutter.dev/cookbook/testing/widget/introduction
void main() { testWidgets("Flutter Widget Test", (WidgetTester tester) async { await tester.pumpWidget(const MyApp()); var button = find.text("NextMonth"); expect(button, findsOneWidget); await tester.tap(button); await tester.pump(); var visibleDates = getVisibleDates(); final DateTime nextMonth = visibleDates[0]; expect(nextMonth.month, DateTime.december); expect(nextMonth, DateTime(2022, 12)); }); }
flutter test./test/widget_testing.dart
I have attached a sample of the same. Please find the attached sample.
Can you add the sample code to add a Widget Test for calendar