I have a pipeline for my Go project. In stages for the unit tests, i use go-junit-report to generate a xml file for test reports which are supposed to appear in the tests tab on GitLab.
For some reason test results stopped showing up, with the following error message:
JUnit XML parsing failed: 9:25: FATAL: Unregistered error message
After some searching, I discovered that there are non-ASCII characters in the report.xml file. I'm not sure if it's the reason for the test results not showing up. And I'm not sure how to remove them. I found this solution to remove non-ASCII characters from the file, but don't know how to make it work in my case: Remove non-ASCII characters in a file
Here is the script used in the .gitlab-ci.yml file:
test:
stage: build
artifacts:
when: always
expire_in: 30 day
reports:
junit: report.xml
script:
- go install github.com/jstemmer/go-junit-report/v2@v2.0.0
- go test -cover -v ./internal/... -coverprofile=unit.coverprofile -tags=unit \
| $GOPATH/bin/go-junit-report -iocopy -set-exit-code -out report.xml
The issue was solved in one of the recent commits in go-junit-report. Replacing:
go install github.com/jstemmer/go-junit-report/v2@v2.0.0
With
go install github.com/jstemmer/go-junit-report/v2@934b104ddd2
This solves this issue