Does Your Company Need QA Transformation? Here Are the Warning Signs!
In the dynamic landscape of software development, ensuring the highest level of quality
Testing across all interfaces, platforms and architectural components
Product test engineering, Shift-Left testing and digital transformation
Automate tests across all interfaces, platforms and horizontal scaling
Generative AI, Flutter, React Native, Micro-services, Micro-frontends & TestOps
Measure and enhance the efficiency & effectiveness of testing teams & solutions
Offshore Testing Setup as a Service, platform engineering and Modernisation
Flutter Integration Tests: A Comprehensive Guide to Test Reporting
flutter test integration_test/tests/create_todo_test.dart
The result of the test gets printed on the console as shown in the below screenshot. This console message is trivial and has minimum information for the test developer. Whether the test passed or failed.
In this blog, we will explore the various reporting options available. As we grow the number of integration tests, a suffocated reporting mechanism is a must to understand and debug the test failures.
In the previous blog post, we were directly running our command on the terminal. However, to integrate reporting, we will create a “runner.sh” file that contains our test execution commands with reporting, and then execute “runner.sh” .
There are multiple reporting options available for Flutter Dart, including
Dot Dart reports are available with the package named dart_dot_reporter available at https://pub.dev/packages/dart_dot_reporter.
By activating the dot dart report, we can save the test execution result data in the testResults.log file. With the help of the dot dart package, we can retrieve and display a summary of the passed and failed test cases.
To obtain detailed information on the causes of the failures, you would have to refer to the testResults.log file. Our runner.sh file will resemble the following code snippet –
flutter pub global activate dart_dot_reporter
flutter test --machine integration_test/tests/create_todo_test.dart > testResults.log
dart_dot_reporter testResults.log
The output would look like this –
The primary benefit of using JUnit XML reports instead of Dot Dart is that JUnit XML files can be uploaded to GitHub or similar platforms, allowing for the results to be displayed in HTML format and maintaining a history of test cases when integrated with version control systems or Jenkins.
To achieve this, the package “https://pub.dev/packages/junitreport” can be used. Results can be stored in a log file similar to how it is done with Dot Dart, and by enabling the JUnit report feature, the log file can be used to generate JUnit XML reports.
Our runner.sh file will resemble the following code snippet –
flutter pub get junitreport
export PATH="$PATH":"$HOME/.pub-cache/bin"
flutter pub global activate junitreport
junitReportFile="./junit-report.xml" # My Report file path, You can give any path suitable to you
flutter test --machine integration_test/tests/create_todo_test.dart | tojunit --output $junitReportFile
After execution, a file named “junit-report.xml” will be generated in the root directory of your code, containing details of the test cases, including reasons for failure.
If you’re interested in exporting the JUnit XML file in HTML format on Source Code Management, you can refer to this article for further guidance: https://medium.com/testvagrant/flutter-integration-test-junit-report-generation-with-gitlab-integration-cebf389e011e
On the other note, there are many tools and techniques available to generate HTML out of JUnit XML and you could choose the one that suits you the most.
flutter pub get junitreport
export PATH="$PATH":"$HOME/.pub-cache/bin"
flutter pub global activate junitreport
junitReportFile="./junit-report.xml" # My Report file path, You can give any path suitable to you
flutter pub global activate dart_dot_reporter
flutter test --machine integration_test/tests/create_todo_test.dart > testResults.log
dart_dot_reporter testResults.log
tojunit --input testResults.log --output $junitReportFile
To run Flutter tests with Gradle, it’s necessary to set up Gradle with AndroidJUnitRunner. To do so, please refer to the setup guide available at https://github.com/flutter/flutter/tree/main/packages/integration_test#android-device-testing.
Our runner.sh file will look like this –
pushd android
# flutter build generates files in android/ for building the app
flutter build apk
./gradlew app:assembleAndroidTest
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../integration_test/tests/create_todo_test.dart
popd
The report with HTML will be present inside –build/app/reports/androidTests/connected/index.html
Please note that this reporting technique is only for the Android platform.
In the dynamic landscape of software development, ensuring the highest level of quality
Rapid Test Development Platform meets Next-Generation Mobile Apps and Cross Browser Testing Cloud
Share This Article