Hi,
I would like to use Test Reports dashboard in my Flutter build workflow, but I’m unable to correctly export a junit test report.
I have a following step:
- script@1.1.5:
inputs:
- content: |
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
brew tap dart-lang/dart
brew install dart # dart for junitreport
cd $BITRISE_SOURCE_DIR/$BITRISE_FLUTTER_PROJECT_LOCATION
mkdir tests
flutter pub pub global activate junitreport
export PATH="$PATH":"$HOME/.pub-cache/bin"
flutter test --machine | tojunit > $BITRISE_SOURCE_DIR/$BITRISE_FLUTTER_PROJECT_LOCATION/tests/TEST-report.xml
- deploy-to-bitrise-io@1.4.2:
inputs:
- deploy_path: "$BITRISE_FLUTTER_PROJECT_LOCATION/tests"
This runs flutter tests and exports the results to TEST-report.xml (junit file).
In logs I can see that deploy executes with success:
Deploying the content of the Deploy directory separately
List of files to deploy
- /Users/vagrant/git/mobile/app/tests/TEST-report.xml
Deploying files
Uploading file: /Users/vagrant/git/app/employee/tests/TEST-report.xml
creating artifact
file size: 3608B
uploading artifact
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 3608 0 0 100 3608 0 13550 --:--:-- --:--:-- --:--:-- 13563
finishing artifact
is_enable_public_page is set, but public download isn't allowed for this type of file
Success
You can find the Artifact on Bitrise, on the Build's page: https://app.bitrise.io/build/8aca429a3e5e3c2f
Upload test results
- uploading (0) test results
Success
However, TEST-results.xml file is not recognized as test result. Is there any way to manually set this file as a source for tests results?
Ok, I found a partial solution myself. One thing I miss is the step-info.json file. Is there any way to generate it or mock it?
The directory where test reports should go is defined here as $BITRISE_TEST_DEPLOY_DIR. So I export my test report as follows:
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
# set -x
brew tap dart-lang/dart
brew install dart
cd $BITRISE_SOURCE_DIR/$BITRISE_FLUTTER_PROJECT_LOCATION
flutter pub pub global activate junitreport
export PATH="$PATH":"$HOME/.pub-cache/bin"
TEST_RESULT=`flutter test --machine | tojunit`
mkdir $BITRISE_TEST_DEPLOY_DIR/test_result123456/
echo $TEST_RESULT > $BITRISE_TEST_DEPLOY_DIR/test_result123456/TEST-report.xml
touch $BITRISE_TEST_DEPLOY_DIR/test_result123456/step-info.json # how to generate it?
I’m not sure how does this work with an ordinary console step. Now my step does not produce step-info.json in BITRISE_TEST_DEPLOY_DIR. I discovered while studying Xcode and Android unit test steps that you have golang utilities to create and export this file e.g. here. Can I use them from shell script?
I also tried to modify current flutter test step to produce correct artifacts but with no success. You can take a look at my trial here.