Appium & Flutter for Testing Mobile Apps: The Tradeoffs
December 23, 2021

Benefits and Limitations of Integration Testing on Flutter

Mobile Application Testing

From BMW to Nubank, applications built in Flutter continue to grow in popularity. As more organizations use Flutter for their mobile apps, finding the best way to test them is increasingly important. 

In this blog, we’ll share how to properly test your Flutter applications as well as how to perform integration testing on Flutter. 

Types of Automated Flutter Tests 

There are three types of tests that go into testing a Flutter application properly: 

  • Unit testing. These tests validate the behavior of a single method, function, or class. 
  • Widget testing. This verifies that the widget’s UI looks and behaves as expected when responding to certain interactions. 
  • Integration testing. These tests verify application performance and ensure that all the services and widgets under test work together properly. 

While unit testing and widget testing typically fall under the purview of the development team, testers are often the ones responsible for integration testing. 

Testers must write these integration tests and determine that they run properly on each device of their choosing. These devices can be locally hosted or cloud based. Unlike unit and widget testing, integration tests are the only ones that test the application in its entirety. 

Let’s dive into the specifics of integration testing—including the capabilities and limitations of doing so using the Native Flutter Framework. 

Integration Testing Using the Native Flutter Framework 

Testers can run integration tests natively in the Flutter framework using Dart, an easy-to-use non-programming language that is like Java. Integration tests in Flutter follow these steps: 

  1. Create an app to test. 
  2. Add the flutter_driver dependency. 
  3. Create the test files. 
  4. Instrument the app. 
  5. Write the integration tests. 
  6. Run the integration test. 
Sample Flutter integration test.
Sample Flutter integration test.

Features & Benefits 

The major difference between Flutter and other frameworks like Espresso and XCUITest is that the Flutter script under test applies to both Android and iOS apps (since Flutter enables developers to build both types of application with one single codebase). 

Additionally, native Flutter tests can easily handle the new features that come with each release. For example, Flutter’s 2.5 release in September 2021 offers support for Android Full Screen edge-to-edge mode, ScrollUnder support within the Material Design, and the ability to do static code analysis of the Dart code. 

Another Flutter feature that is especially relevant to testing is the Flutter inspector. Inspector helps testers visualize and explore Flutter widget trees, which helps them get the element properties needed for writing integration tests. This is a major advantage for testing Flutter apps within the native Flutter framework. 

Considerations & Limitations 

It is important to keep in mind that the Flutter framework has some testing limitations to the Flutter application under test. Therefore, testing events that happen outside the context of the application on a mobile device are not supported. 

Here are some limitations to be aware of when using the Native Flutter Framework: 

  • Biometrics are not supported for integration testing 
  • Network virtualization profiles are not supported 
  • Accessibility support (Native scanners, IDs) are not supported 
  • Development languages supported: Dart only 
  • Only tests application under test (AUT) for Web, Mobile and Desktop 
  • Limitations with Android Popups 
  • The following test automation scenarios are not supported: 
    • Image injection 
    • 2FA 
    • Audio testing 
    • Visual analysis 
    • Location injection 

See it in Action 

Watch the video for a brief demo of Flutter testing within the Perfecto Cloud: 

 

Bottom Line 

If you’re using Flutter to build your mobile apps, it’s crucial to test them properly—which includes having a thorough understanding of the features and limitations of how to run automated tests natively in the Flutter framework. 

Want to learn more? Connect with us! 

Request a 1:1 demo with a Perfecto expert.  

Get Demo