Flutter is a new cutting-edge open source technology which is highly beneficial for organisations looking to reduce the time for product development and release products faster to the market. Its biggest advantage is that it provides the same code base for both Android and iOS.
Testing Apps developed on Flutter requires specialised skills, especially automation. There are 3 different types of testing done on Flutter Apps:
- Golden Tests
- Widget Tests
- Integration Tests
All these tests require working closer with the Flutter technology and Dart Programming language. In this interactive talk I would like to go through some of the concepts around these Flutter Tests.
The Golden Tests entail testing snapshots which match a baseline image with the current image from the latest build. This provides quick feedback about what has been changed in the latest upcoming releases and also provides a note of any image distortions/changes. Every field (Buttons, Icons, Text fields etc) in Flutter is termed as a Widget, so any test that examines these fields is termed as Widget Tests. These tests primarily verify anything and everything that is done by these Widgets; for example, placing/action on the Widget.
The Integration Tests, as the name suggests, enable testing the integration of Widgets and their functionalities. All these types of tests are scripted within the same repository as the project and use the same programming language of Dart and Flutter Technology. This enables us to work more closely with the Developers and create better quality products. Testing of apps developed on Flutter needs different skill sets, with respect to our approach towards it. Typically, in the Flutter terminology, the Flutter Integration Tests are generally considered as the UI End-End Tests. These tests can be written in dart programming language and combined with the Developer’s code and pipeline. This helps us to run the tests, every time the development pipeline runs, providing the feedback early and in time. Also, as we very well know, quick feedback is directly related to the cost associated with the product, hence this method reduces the overall costs of the project/product.
The Widget Tests on the other hand provide us with a very unique way of testing all the widgets available in an app. Quite often, while running our UI Tests, we sometimes unknowingly skip some of the Widgets on the screen This could be because that particular widget is not needed for our tests. Invariably, a lot of times, this particular widget could lead to a bug later in the cycle. These types of Widget Tests could help us in testing every single Widget on the screen beforehand and enable us in identifying potential bugs much early in the product’s development and release cycle.
Primarily there are 2 different Ways to Test an App developed in Flutter:
- Appium's Flutter Driver: This is very much similar to using the Appium driver and interacting with the elements like we do for any other Apps. Thanks to the great team of Appium contributors for supporting the element identifications and other necessary changes on the Appium framework. It works seamlessly just like any other app, apart from having to handle the element identification issues, which sometimes had to give the longer XPATH's.
- Flutter's Native Integration Test package: Flutter community has started providing an additional 'integration_test' package. This package would be used to perform the Integration Tests depicted in the above section. This enables us to be more closer to the Developer's code, use the same DART language and tailor the code(automation and/or development) as per our needs.
We will go through more details in the session about the differences between these techniques and present our observations.