Flutter Integration Testing: Making Bitrise Work for You!

Aditya Gurjar
4 min readApr 24, 2023

--

Integration tests help you make sure that all the components of your app are interacting properly. However, manually executing these tests can be tedious and time-consuming. That is why we will be looking at how to automate them and save some of that time!

There are a plethora of CI/CD options out there (Codemagic, Bitrise, and Gitlab to name a few). I personally prefer Bitrise and that is what we’ll be using for this setup.

Setting up Bitrise

For the uninitiated, Bitrise is a powerful CI/CD platform that helps you streamline your build, test, and deployment process.

For this example, We’ll keep it simple and use the default Counter App generated by Flutter.

For starters, you need to create a Bitrise account.

Once you’ve created an account, the next step is to set up a new app in Bitrise for your Flutter project. This requires linking your Bitrise account to your version control system (GitHub, Bitbucket, GitLab, etc.) and choosing the relevant repository.

Write a Basic Integration Test

Let’s start by adding integration_test to our app’s pubspec.yaml

And then writing a basic integration test for our counter app.

Verify the test we just by running flutter test integration_test

Writing the workflow

Next, we move on to writing the workflow for running the integration tests on Bitrise. It’ll contain the steps that will clone your repository onto the Bitrise virtual machine, install the Flutter SDK, start a virtual iOS Simulator, and run your integration tests.

Here’s the complete bitrise.yml with the integration-test-appworkflow. All the steps are pretty self-explanatory:

Saving the workflow and triggering a new build, we see everything works okay and all the tests are passed.

And the scheduling!

The final and arguably the most crucial bit is scheduling your integration tests to run automatically at a designated time.

Click on the “Start/Schedule build” button, and specify, at what time, and how frequently you’d like your integration tests to run (daily, weekdays, every alternate day). Here’s a quick clip showing you how to do it:

Once you do that, just wait for the build to run at the scheduled time.

  • Integration tests can often be long-running, so a general rule of thumb is to schedule these tests to run during the night and monitor their reports the next morning.
  • Bitrise automatically takes care of reading the test results and presenting them to you in a neat way.

This was easy!

To sum up, scheduling integration tests in Flutter on Bitrise is a remarkably straightforward and efficient process that can save you a lot of QA time and effort.

Integration Tests ensure that your app’s behavior is predictable, and also allow you to detect potential bugs or issues promptly. So go ahead, try it out, and experience the benefits of automated testing firsthand.

Happy testing!

Part two of this story explains how to use real devices instead of a simulator in the same workflow.

Checkout the complete code with the workflow at:

Have any questions? Reach out to me on Twitter:

Read My Other Blogs

--

--

Aditya Gurjar

Mobile Engineer. Writing Mostly about Mobile Dev, Mobile DevOps, and a lil bit of life.