Testing in Flutter

Testing is one of the important aspect in app development. Testing helps to find and fix bugs, increasing the quality of the application. This course will introduce testing and different types of tests in Flutter. You will learn how to write unit tests, widget tests, and integration tests in Flutter. You will also learn how to write tests for your apps. You will learn how to Generate Goldens for UI Comparison and Automate running tests. By .

Leave a rating/review
Download materials
Save for later
Comments
Share

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.

Covered concepts

  • 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

01
Toggle description

This is an introduction to testing and what are different ways of testing a Flutter app. You will learn importance of testing.

Toggle description

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

Toggle description

In this episode you will see what you are going test and how the project stucture is arranged.

Toggle description

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.

Toggle description

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.

Toggle description

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.

Toggle description

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.

Toggle description

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

Toggle description

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.

Toggle description

Now that we know how to test a text widget. Lets find out other ways to find a widget in the Widget tree.

Toggle description

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.

Toggle description

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

Toggle description

In episode we will learn about integration test and will be reusing the widget tests into integration test

Part 5: Generate Goldens

Toggle description

In this episode we will learn about Goldens and how to generate them.

Toggle description

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.

Toggle description

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.

Toggle description

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

Toggle description

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.

Toggle description

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.