How to add Flutter integration test in a CI with GitHub Action ?
During the development of a project, we need something to make integration testing. And more importantly, use a CI to automatically run the tests. We will see in this article how to make our first integration test and use Github Action to perform the test in a workflow.
We will use GitHub to make our workflow. First, init your repository with git init , then create your .github/workflows/ folders with a file named test-integration.yaml.
The most important action we will use is reactivecircus/android-emulator-runner@v2, we can find the documentation here. It will run an emulator android and execute some script on it.
We will now create the workflow:
The most important in this workflow is the job "Run Flutter Driver tests", the action will start an emulator for us then execute the script provided and here we use the same command as before in local.
And finally, we upload the screenshots in artifact so we can check it later.
We just have to push the file into the repository and the workflow will be triggered:
And if you click on the workflow you should see something like this:
And inside the jobs we see some logs:
And after some minutes you should see:
And if you click on "Summary" you should see your artifact (screenshots):
We can see that our test pass successfully in the CI, and use the emulator provided by reactivecircus .
Thanks to the matrix strategy we can also run the workflow for multi api levels for example this is a workflow with 21, 23, and 29 for target default and google_apis:
We just have to add in the yaml:
You can find all the possible configurations inside the documentation:
We use GitHub action and for the price, it's free for repositories public and we got 2,000 minutes/month for private repo.
All the prices can be found here:
With this workflow, we can now run integration testings directly in GitHub. And see the result/screenshots in an artifact.
Like always if you need to check the code take a look at my repository:
Subscribe to Etienne Théodore
Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.