简体   繁体   中英

go-junit-report failing to parse test results to gitlab

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM