Getting started with Flutter Driver
A mobile app has immensely become a part of everyone’s life these days. People are moving from desktop to mobile apps to get their daily need been served. It becomes very important how fast your mobile app works, what glitches you face on poor/no network connection.
So, testing these apps becomes very important from Go to market perspective and how would you invest automating those user journeys and personas
We are building a mobile platform using Flutter, which provides a flutter driver package to write your automated e2e integration tests.
In this article, I am going to discuss how can we get started writing integration tests using flutter driver. You would see in the next series of the article why flutter driver.
What is integration testing?
An integration test is a set of tests which verify the journey and personas of the app. As part of the integration test, we verify whether all widgets of an app and backend services are integrated or not. Deep dive into integration test: https://martinfowler.com/bliki/IntegrationTest.html
What is Flutter Driver?
Flutter Driver is a testing framework for Flutter Apps which is used to test ui elements and helps to automate e2e journey tests. It is similar to other test frameworks of web and mobile like webdriver, protractor
Pre-requisites/set up for writing flutter driver tests
- Any IDE of your choice visual studio or android studio
- Add the following dependencies in your pubsec.yaml
- Once the dependencies are added, under test_driver folder, we need to create two files: e2e.dart and e2e_test.dart.
- e2e.dart contains a method that will enable the flutter driver extension to call the functions which contain the widgets we need to test.
- The second file would be e2_test.dart where we would have a setup, teardown and test method
- Once these two files are created, you could run the test using the following command: flutter drive — target=test_driver/e2e.dart
There you go, you are all set to start writing flutter driver tests :)
See you soon with the next article:
- Fetch properties based on environment
- Integrating flutter driver with CI pipeline
- Getting started using Flutter Dev Tool
- Pros and Cons of Flutter Driver
- Challenge on writing tests and ways to optimize