• Home
  • Insight
  • Blog
  • Business
  • Entertainment
  • Health
  • Politics
  • Shop
    • Gift Shop
    • Value Shop
    • Store
    • Bargain Shop
    • Discount
  • Sports
  • Tech
  • Travel
  • USA
  • Video
  • World
    • Asia
    • Africa
    • South America
    • North America
    • Europe
    • Oceania
Thursday, July 30, 2026
No Result
View All Result
Subscribe Now
  • Home
  • Insight
  • Blog
  • Business
  • Entertainment
  • Health
  • Politics
  • Shop
    • Gift Shop
    • Value Shop
    • Store
    • Bargain Shop
    • Discount
  • Sports
  • Tech
  • Travel
  • USA
    TX Rep. Brandon Gill Mocks James Talarico Over Fauci Action Figure Post

    TX Rep. Brandon Gill Mocks James Talarico Over Fauci Action Figure Post

    NBA players are ‘being taught’ to flop

    NBA players are ‘being taught’ to flop

    Industry was warned for years about chemical ‘runaway’ dangers. Then came near-catastrophe in O.C.

    Industry was warned for years about chemical ‘runaway’ dangers. Then came near-catastrophe in O.C.

    Trump administration seeks government-wide NDAs to stop leaks : NPR

    Trump administration seeks government-wide NDAs to stop leaks : NPR

    Dog discharges shotgun inside truck, striking woman at Nebraska traffic light

    Dog discharges shotgun inside truck, striking woman at Nebraska traffic light

    Toshifumi Suzuki, Japan’s ‘God’ of Convenience Stores, Dies at 93

    Toshifumi Suzuki, Japan’s ‘God’ of Convenience Stores, Dies at 93

     Judge Sanctioned CoreCivic for Destroying Video in ICE Death Suit

     Judge Sanctioned CoreCivic for Destroying Video in ICE Death Suit

    Suspect dead after opening fire near White House security checkpoint, Secret Service says

    Suspect dead after opening fire near White House security checkpoint, Secret Service says

    Trump trashes Colbert’s high-rated finale as “no ratings”

    Trump trashes Colbert’s high-rated finale as “no ratings”

  • Video
  • World
    • Asia
    • Africa
    • South America
    • North America
    • Europe
    • Oceania
The Insight Post
  • Home
  • Insight
  • Blog
  • Business
  • Entertainment
  • Health
  • Politics
  • Shop
    • Gift Shop
    • Value Shop
    • Store
    • Bargain Shop
    • Discount
  • Sports
  • Tech
  • Travel
  • USA
    TX Rep. Brandon Gill Mocks James Talarico Over Fauci Action Figure Post

    TX Rep. Brandon Gill Mocks James Talarico Over Fauci Action Figure Post

    NBA players are ‘being taught’ to flop

    NBA players are ‘being taught’ to flop

    Industry was warned for years about chemical ‘runaway’ dangers. Then came near-catastrophe in O.C.

    Industry was warned for years about chemical ‘runaway’ dangers. Then came near-catastrophe in O.C.

    Trump administration seeks government-wide NDAs to stop leaks : NPR

    Trump administration seeks government-wide NDAs to stop leaks : NPR

    Dog discharges shotgun inside truck, striking woman at Nebraska traffic light

    Dog discharges shotgun inside truck, striking woman at Nebraska traffic light

    Toshifumi Suzuki, Japan’s ‘God’ of Convenience Stores, Dies at 93

    Toshifumi Suzuki, Japan’s ‘God’ of Convenience Stores, Dies at 93

     Judge Sanctioned CoreCivic for Destroying Video in ICE Death Suit

     Judge Sanctioned CoreCivic for Destroying Video in ICE Death Suit

    Suspect dead after opening fire near White House security checkpoint, Secret Service says

    Suspect dead after opening fire near White House security checkpoint, Secret Service says

    Trump trashes Colbert’s high-rated finale as “no ratings”

    Trump trashes Colbert’s high-rated finale as “no ratings”

  • Video
  • World
    • Asia
    • Africa
    • South America
    • North America
    • Europe
    • Oceania
No Result
View All Result
No Result
View All Result
Home Mobile

Full-stack testing of Flutter apps with Codemagic CI/CD

by Theinsightpost
August 19, 2022
in Mobile
0 0
0
Full-stack testing of Flutter apps with Codemagic CI/CD


Flutter is booming in the field of cross-platform mobile application development. Whilst developers can create solid apps with Flutter, they also have to ensure that the existing functionality is not broken by the latest code changes. In order to get that confidence, developers can write a layer of automated tests. It is also important to run the automated tests on a regular basis or on every code change to get continuous feedback, this is where continuous integration comes into the picture. Since it was announced at Flutter Live in 2018, Codemagic has become the official CI/CD solution for Flutter apps, so we can easily integrate Flutter’s automated tests on Codemagic without any configuration.

In this post, we will explore how to integrate Flutter tests on Codemagic.

About testing Flutter apps

Flutter has a richer set of testing features than any other cross-platform mobile app development framework. Flutter provides a solid testing framework which allows developers to write tests at unit, functional and UI level. Widget testing is one cool feature that Flutter provides to run UI tests as fast as unit tests. Flutter also has UI tests, known as integration tests, that run on the simulator or on real devices.

Flutter has cool documentation on how to test Flutter apps at different levels with example code. We will briefly cover all layers of Flutter tests using the Codemagic-Demo app.

Enabling testing in Flutter apps

In order to test Flutter apps, we need to understand the different levels of testing and add the Dart packages to enable Flutter testing. There are packages like flutter_test and flutter_driver to support the testing of Flutter apps. The first step is to add those dependencies in the Flutter app. Flutter uses the pub package manager to manage all the Dart dependencies. The dependencies are usually stored in the pubspec.yaml. We can add our testing dependencies there.

dev_dependencies:
  flutter_test:
    sdk: flutter
  test: ^1.5.1

At the moment, we can use a stable test version above 1.5.1 to get the unit tests working. There was a breaking change in the API as mentioned here. Once we have all the testing dependencies in place, we can just update the Flutter dependencies using the following command:

We have now added the testing dependencies to our Flutter project. The versions of all the dependencies are locked in the pubspec.lock file. We can now import all the testing packages in our tests. We also need to create the test directory for storing all our unit and widget tests. If we want to enable integration testing, then we need to create the test_driver directory to store all the code for our instrumented app and integration tests.

Unit testing

The purpose of unit tests is to verify that a single unit or method works well with different conditions or parameters. Flutter unit tests can be added with the package package:test and by adding the tests into the test directory at the root of the project. We can add a simple unit test by creating a file test/unit_test.dart with the following code:

import 'package:test/test.dart';

void main() {
  test('Test Addition', () {
    var answer = 42;
    expect(answer, 40+2);
  });
}

This test will verify if the addition works with different inputs and we can expect correct values. This is a very basic unit test, but in reality, we can add unit tests for the modules we write in apps. We can run the unit tests locally using the flutter test command. This command will run all the tests inside the test directory. If you want to run an individual unit test, we can run it by passing the relative path, like this:

flutter test test/unit_test.dart

Widget testing

The widget testing feature of Flutter allows developers to verify the functionality of the widgets used in the app. We can launch a widget as part of the test and perform actions as real users do on the widget. An amazing thing about widget testing is that widget tests run as fast as unit tests whilst going through the UI. There are barely any other test frameworks which have this kind of feature. The widget tests for Flutter come up in the package:flutter_test package and have fluent API documentation available here.

We can add a widget test for our Codemagic-Demo app by creating a test/smoke_test.dart file with the following content:

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_demo/main.dart';

void main() {
  testWidgets('smoke test', (WidgetTester tester) async {
    final app = MyApp();
    await tester.pumpWidget(app);
    expect(find.text("0"), findsOneWidget);
    await tester.tap(find.byIcon(Icons.add));
    await tester.pump();
    expect(find.text("1"), findsOneWidget);
  });
}

This test launches the Flutter demo app, pumps the widgets, asserts that the count is initially 0 and then taps on the add icon to assert that the count has been incremented to 1. You can see that this test covers a lot of user actions but with incredibly fast speed. We can run this test similarly to unit tests with the flutter doctor command. The widget testing feature is truly amazing.

Integration testing

Flutter integration tests are similar to Xcode UI tests or Android Espresso tests which go through the UI to perform specific operations. Flutter integration tests run in a separate process and can be run on real devices or on simulators or emulators. Flutter provides a separate package, Flutter Driver, to drive these tests. In order to enable those tests in our app, we have to add the flutter_driver package to pubspec.yaml and write integration tests in the test_driver directory at the root of the project.

We also need to create an instrumented app and enable the Flutter Driver extension using the enableFlutterDriverExtension() method. You can find the details of the setup on Flutter documentation, or read an excellent post on how to set up integration testing for a Flutter app here.

We have written an integration test to test the message on the screen here. We can run this test locally using the flutter drive command as follows:

flutter drive -target=test_driver/main.dart

This test will launch the app on the simulator or the emulator and will then assert that the message appears on the screen.

We can set up integration tests on real devices and watch them run to gain confidence in the app.

Testing Flutter apps on Codemagic

We have seen how to run Flutter tests locally, but in order to run them on a regular basis on every code change, we need a continuous integration server. The process of setting up the tests on a CI server usually requires some setup and configuration, but with Codemagic it is entirely painless, as:

  • Codemagic analyzes the Flutter project and provides an option to enable the Flutter tests;
  • Codemagic also scans the code for integration tests and provides an option to enable the Flutter driver tests.

Codemagic has become the de-facto tool for CI/CD of Flutter apps. The Codemagic getting started guide covers the onboarding process of Flutter apps. Now, we will cover the testing part in details.

What we need?

  • Github, Bitbucket or GitLab account to get access to Codemagic
  • Flutter app with unit, widget and integration tests. Integration tests are optional but good to have in a Flutter app

That’s it! We are all set to run Flutter tests on Codemagic. In this tutorial, we will use a demo app Codemagic-Demo which has unit, widget and integration tests.

Once you have access to Codemagic, Codemagic will detect your Flutter project and tests. You don’t have to explicitly do anything to enable testing of the Flutter app unless your tests use a custom configuration.

Codemagic testing related features

  • Widget testing: Out-of-the-box support for unit and widget tests using Flutter Test
  • Widget testing without building apps to save build time.
  • UI testing: Support for integration tests with Flutter Drive.
  • Fail fast approach: Codemagic runs the tests before building iOS and Android apps which saves time if some of the tests fail. We can also stop the build if a test fails.
  • Pre-test and post-test actions: In cas, you need to upload the test artifacts to some other services or install some packages just before test starts. This feature is great to customize Flutter testing.

Running tests

You can enable testing in the Test section of app settings.. In most cases, Codemagic will detect the Flutter project along with the tests and enable them for you by default. You can then explicitly choose which tests you want to run as part of the build process.

Running Flutter tests

Once we have enabled the tests, we have to save the configuration and trigger a new build. The newly triggered build will run all our tests with the results printed in the console.

Running Flutter tests

We can also see detailed verbose logs of the tests on the Log tab in test reports. In the case of the Flutter drive test, we got the logs in the console as shown below.

Flutter testing

When a test fails, Codemagic will stop the build and send an email with the test report and a link to the build logs.

Cover different testing scenarios

We have just seen how easy it is to get started with testing Flutter apps on Codemagic. However, there are some other complex test execution builds we can run on Codemagic by creating custom workflows. For example:

  • You may want to trigger only unit and widget tests on the feature branch and keep the UI tests for the master branch.
  • You may want to run UI tests and performance tests on specific branches.
  • You can run only widget tests without building app to get quick feedback.

You can easily achieve those scenarios by creating multiple workflows. Simply specify the branches to build in the Build triggering section of app settings and choose which tests to run.

Source code

You can find the source code of all the Flutter tests described here on the Codemagic-Demo app on GitHub. You can clone the project and run widget and integration tests as follows:

git clone https://github.com/Shashikant86/Codemagic-Demo
cd Codemagic-Demo
flutter test
flutter drive --target=test_driver/main.dart

Conclusion

Getting regular feedback on your automated tests is critical in mobile app development. Flutter provides a great automated testing framework to test the app at unit, widget and integration level. With Codemagic, we can automate running the automated tests as part of continuous integration without any setup or configuration.



Source link

ShareTweetSend
Previous Post

Worsening drought threatens lives in eastern Kenya

Next Post

Germany lowers natural gas tax to ease burden on consumers

Related News

Announcing Codemagic Patch: an open-source CodePush rebuild for React Native
Mobile

Announcing Codemagic Patch: an open-source CodePush rebuild for React Native

July 30, 2026
React Native OTA Updates: What You Can (and Can’t) Deploy Over the Air
Mobile

React Native OTA Updates: What You Can (and Can’t) Deploy Over the Air

May 28, 2026
Your phone drawer hides an app designed to “exploit developing brains”
Mobile

Your phone drawer hides an app designed to “exploit developing brains”

May 27, 2026
iPhone 16 has a secret charging upgrade Apple didn’t even mention
Mobile

iPhone 16 has a secret charging upgrade Apple didn’t even mention

May 26, 2026
Next Post
Germany lowers natural gas tax to ease burden on consumers

Germany lowers natural gas tax to ease burden on consumers

Discussion about this post

Subscribe To Our Newsletters

    Customer Support


    1251 Wilcrest Drive
    Houston, Texas
    77042 USA
    Call-832.795.1420
    e-mail – news@theinsightpost.com

    Subscribe To Our Newsletters

      Categories

      • Africa
      • Africa-East
      • African Sports
      • American Sports
      • Arts
      • Asia
      • Australia
      • Business
      • Business Asia
      • Business- Africa
      • Canada
      • Defense
      • Education
      • Egypt
      • Energy
      • Entertainment
      • Europe
      • European Soccer
      • Finance
      • Germany
      • Ghana
      • Health
      • Insight
      • International
      • Investing
      • Japan
      • Latest Headlines
      • Life & Living
      • Markets
      • Mobile
      • Movies
      • New Zealand
      • Nigeria
      • Politics
      • Scholarships
      • Science
      • South Africa
      • South America
      • Sports
      • Tech
      • Travel
      • UK
      • USA
      • Weather
      • World
      No Result
      View All Result

      Recent News

      Free Cloud Computing Course | AWS Re/Start Program 

      Free Cloud Computing Course | AWS Re/Start Program 

      July 30, 2026
      Thirty Years Later

      Thirty Years Later

      July 30, 2026
      Announcing Codemagic Patch: an open-source CodePush rebuild for React Native

      Announcing Codemagic Patch: an open-source CodePush rebuild for React Native

      July 30, 2026
      Following Expansion in China, Regional Private Equity Faces New Scrutiny in Southeast Asia – The Diplomat

      Following Expansion in China, Regional Private Equity Faces New Scrutiny in Southeast Asia – The Diplomat

      July 30, 2026
      • Home
      • Advertise With Us
      • About Us
      • Corporate
      • Consumer Rewards
      • Forum
      • Privacy Policy
      • Social Trends

      Theinsightpost ©2026 | All Rights Reserved. Theinsightpost is an Elnegy LLC company, registered in Texas, USA

      Welcome Back!

      Login to your account below

      Forgotten Password?

      Retrieve your password

      Please enter your username or email address to reset your password.

      Log In

      Add New Playlist

      We are using cookies to give you the best experience on our website.

      You can find out more about which cookies we are using or switch them off in .

      No Result
      View All Result
      • Home
      • Insight
      • Blog
      • Business
      • Entertainment
      • Health
      • Politics
      • Shop
        • Gift Shop
        • Value Shop
        • Store
        • Bargain Shop
        • Discount
      • Sports
      • Tech
      • Travel
      • USA
      • Video
      • World
        • Asia
        • Africa
        • South America
        • North America
        • Europe
        • Oceania

      Theinsightpost ©2026 | All Rights Reserved. Theinsightpost is an Elnegy LLC company, registered in Texas, USA

      The Insight Post
      Powered by  GDPR Cookie Compliance
      Privacy Overview

      This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

      Strictly Necessary Cookies

      Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

      Cookie Policy

      More information about our Cookie Policy