I'm trying to fully integrate our JUnit Suites into gitlab and struggling with the output on the "tests" tab.
What I have is a results summary given the .gitlab-ci.yml
step, what I'd like is a breakdown of each tests name/time to complete/status.
When I look inside the TEST*Name_of_Test.xml I can see the individual tests with their time breakdowns:
Here's what my stage looks like in the gitlab-ci.yml
config:
Anyone have suggestions as to how I could properly configure the gitlab-ci.yml
stage to get the broken-out unit tests run?
While not a perfect solution. This is a work around, see image result:
Here's what I had to do:
It looks like this: fixJunitReports.sh
#!/bin/bash
totalTime=0;
totalTests=0;
totalErrors=0;
totalSkipped=0;
totalFailures=0;
for testResult in $1/target/surefire-reports/*TEST*.xml ; do
tsName=$(grep -Pio '<testsuite.*name="\K[^"]*' $testResult)
tsTime=$(grep -Pio '<testsuite.*time="\K[^"]*' $testResult)
totalTime=$(echo "$totalTime $tsTime" | awk '{print $1 + $2}');
tsTests=$(grep -Pio '<testsuite.*tests="\K[^"]*' $testResult)
totalTests=$((totalTests+tsTests));
tsErrors=$(grep -Pio '<testsuite.*errors="\K[^"]*' $testResult)
totalErrors=$((totalErrors+tsErrors));
tsSkipped=$(grep -Pio '<testsuite.*skipped="\K[^"]*' $testResult)
totalSkipped=$((totalSkipped+tsSkipped));
tsFailures=$(grep -Pio '<testsuite.*failures="\K[^"]*' $testResult)
totalFailures=$((totalFailures+tsFailures));
done
# Now build master file.
rm -f $1/target/surefire-reports/junit_report.xml
echo '<?xml version="1.0" encoding="UTF-8" ?>' >> $1/target/surefire-reports/junit_report.xml
echo '<testsuites id="junit_run" name="'$tsName'" tests="'$totalTests'" failures="'$totalFailures'" time="'$totalTime'">' >> $1/target/surefire-reports/junit_report.xml
tail --lines=+2 $1/target/surefire-reports/*TEST*.xml >> $1/target/surefire-reports/junit_report.xml
echo '</testsuites>' >> $1/target/surefire-reports/junit_report.xml