Flutter Integration Test: JUnit Report Generation with Gitlab Integration

Flutter is an open source framework by Google for building beautiful, natively compiled, multi-platform applications from a single codebase. It provides smooth integration for integration testing also. To do a setup for integration testing, You can refer Flutter Integration Testing Doc.

Prerequisite :

  1. A repository that has some integration tests for the flutter app.

If You need a reference, you can make a clone of my repository. Flutter Integration Test Setup Project Reference.

2. You should be able to run the test on Your local.

JUnit Report Integration On Your Local Machine:

  1. Dart provides one package for JUnit Report, JUnit Package
  2. We will create a shell file to run our Test script. Let's Say the File name of the shell script is — testRunner.sh
  3. We will install the Junit package using flutter and will activate it for reporting.
  4. We will write our command to run the flutter integration test and store the results in JUnit XML report format.
Install Junit Package and Activate Junit Report

Update your Runner shell file with the above content and run this Shell file. Once your execution will be completed, the test result will be stored in the ./junit-report.xml file.

Running Test on GitLab Runner and Generating JUnit Report:

we will create a simple gitlab.yml file that will run the above shell script. You can enhance the same based on your requirement and configurations.

gitlab yml file

Yeah, In the above steps we created a simple gitlab.yml file that will execute our shell script. As per our above shell script, it will store all execution data in Junit Report File i.e './junit-report.xml'.

we will store the XML file as an artifact for each pipeline execution, that would be helpful to get more logs and failure results. We can generate the trend also with the same.

Till now we are good with integrating the test execution with GitLab and generating readable reports and storing previous reports as artifacts.

One thing you will notice with your execution is, In all cases whether tests are passed or failed, Your pipeline's status will come as PASSED. This is due to the case that, on flutter test execution, if some test cases failed, it gives only errors instead of showing as failure in the JUnit report. Due to this reason, pipeline status always comes as PASSED.

The above drawback could be misleading in some situations. For example, You have integrated slack/email notification on pipeline failure. But due to the above issue, your notification will always indicate that pipeline is passed.

To achieve the correct status of the pipeline, we will update our above shell script file.

Now we are all set . If Any test will fail, You will get FAILED status and if all Test passed, You will get PASSED status.

References -

Happy Learning..




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Amazon OA Question — Different types of pages — Y Tech

The how and why of Flutter App Development with an Example

RMS, titanic

I will build a responsive eCommerce website using Woocommerce

Don’ts while installing Custom ROM on Moto G5s Plus!

CS, dynamic programming

Flask: Before and After request Decorators

Behind the Scenes of My First CLI Program

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akanksha Gupta

Akanksha Gupta


More from Medium

Testing using Idling Resources in Espresso

How To Make Your Test Automation Framework Scalable by Design

How to convert the Flutter project to null safety without hassle

Why Recording Videos for Automated Test Execution in Test Scripts is Wrong?