Who is this for?
New and intermediate Flutter developers who want to learn how to test their apps. This course is for developers who want to learn how to write unit tests, widget tests, and integration tests in Flutter. QA team to learn how to write tests or how testing works in Flutter.
- Introduction to Testing in Flutter
- Types of Tests
- Writing Unit Test
- Mocking Unit Test Data
- Writing Widget Test
- Override Riverpod Dependencies with mock data
- Support Multiple Screen Size and Extending Widget Test
- Generating Goldens for UI Comparison
- Understanding Goldens
- Integration Test
- Reusing Widget Test for Integration Test
- Generating Coverage Report
- Automate running tests
Part 1: Introduction to Testing
This is an introduction to testing and what are different ways of testing a Flutter app. You will learn importance of testing.
In this episode you will learn the different types of tests present in flutter and their use cases. You will also learn when to use which type of test.
Part 2: Write Unit Tests
In this episode you will see what you are going test and how the project stucture is arranged.
Your First Unit Test
You are going to start with Unit Tests. Unit test are useful to test a function. In this episode you will be writing your first unit test.
Test Change Notifier
We are going to test the change notifier. Change notifier is a class which notifies the listeners when there is a change in the state. In this episode you will be writing your first unit test for the change notifier.
In this episode, you will learn about mocking. You will be learning how to mock a class and how to mock data. You will be writing your first mock test. You will also learn how to use third-party packages to mock data.
Test Quotes Notifier
In the last episode, you learned about mocks, creating your mock data, and using Mocktail package to make mock data for you. In this episode, you will learn how to use Mocktail package to write your test and test the functionality of the QuotesNotifier class.
Mock API Requests
API requests are an integral part of any app. And we may have some bugs in the HTTPS function. Testing API requests is critical. In this episode, you will write tests to test the API requests. You will be writing tests to test the Quotes API and the Quotes Service.
Part 3: Write Widget Tests
Now that we are done with unit tests let’s explore widget testing. In this episode, you will learn how to widget test the login screen.
Find & Pump Widget
Now that we know how to test a text widget. Lets find out other ways to find a widget in the Widget tree.
In the previous episode we tested the login screen widget. In this episode we will learn how to test the login screen widget with different scenarios.
We will mock the Quotes data and override the Riverpod dependencies to test the Quotes screen.
Test Quotes Page
Now that we are done testing the login page. Lets test the Quotes page. We will mock the Quotes data and override the Riverpod dependencies to test the Quotes screen.
Part 4: Getting Started With Integration Test
In episode we will learn about integration test and will be reusing the widget tests into integration test
Part 5: Generate Goldens
In this episode we will learn about Goldens and how to generate them.
In this episode, we will create an extension function that will help us to generate goldens files and also allow us to test various screen sizes.
We will create a new helper function that will help us create goldens in a better way. We will also use the newly created testMultipleScreenSize function to test our widget for multiple screen sizes.
We will use the newly created goldens function to generate goldens and fix the integration test failure. We will also add fonts to goldens.
Part 6: Generate Coverage Report
In this episode, we will learn how to generate the code coverage report for our test. The code coverage report shows how much of our code is covered by the test. This helps us identify the code not covered by the test, and we can write a test for that code.
In this episode, we will add a test case for the code not covered by our previous test. We will learn how to create a sh file to run the test and generate code coverage reports.