Flutter: Deep Dive with Widget Tests and Mockito
Вставка
- Опубліковано 31 лип 2024
- Full source code on GitHub: github.com/bizz84/coding-with...
Sign up here for more videos: codewithandrea.com/
In this video I cover widget tests in depth.
This will give you a solid understanding about testing in Flutter, so that you can ensure your widgets behave as expected.
This is based on my Firebase authentication demo, which I have covered in my previous videos.
Highlights:
00:00 - Intro
00:17 - Overview of Widget tests: what they are and what they are used for
02:06 - Widget tests in the Flutter Sample Demo App: WidgetTester, Finder, and matcher objects explained
05:15 - Explanation of WidgetTester.pump().
08:00 - How to write Widget tests for a login screen
10:45 - Resolving problems with MediaQuery
14:45 - Introduction to test mocks, and how to write one
19:18 - Introduction to mockito as a powerful tool to mock objects
21:53 - From Acceptance Criteria to Widget Tests, in detail
22:40 - Finding widgets by key
24:10 - Write expectations with mockito
25:40 - Detecting callbacks
28:40 - How to enter text into a widget
31:15 - Use mocks to return values and throw errors
35:33 - Wrap up
Notes:
- I'm using the iOS simulator, but you can open the Android emulator and run the same code.
- To run the code on the demo, follow the instructions on the project README file to setup your own Firebase instance.
If you need any help, just ask in the comments. I'll be happy to help.
Feedback and suggestions on new tutorials are very welcome!
This code was written with Flutter Beta 0.5.1, and is tested to work with Dart 2.
For a more in-depth coverage of unit & widget testing, see my Flutter & Firebase course: codewithandrea.com/courses/fl...
Thanks for watching! - Наука та технологія