我的 Go 项目有一个管道。在单元测试阶段,我使用 go-junit-report 为测试报告生成一个 xml 文件,该文件应该出现在 GitLab 的测试选项卡中。由于某种原因,测试结果停止显示,并显示以下错误消息:JUnit XML parsing failed: 9:25: FATAL: Unregistered error message经过一番查找,我发现report.xml文件中有非ASCII字符。我不确定这是否是测试结果未显示的原因。而且我不确定如何删除它们。我发现此解决方案可从文件中删除非 ASCII 字符,但不知道如何使其适用于我的情况: 删除文件中的非 ASCII 字符这是 .gitlab-ci.yml 文件中使用的脚本: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
1 回答

守着一只汪
TA贡献1872条经验 获得超4个赞
这个问题在 go-junit-report 中最近的一个提交中得到了解决。更换:
go install github.com/jstemmer/go-junit-report/v2@v2.0.0
和
go install github.com/jstemmer/go-junit-report/v2@934b104ddd2
这解决了这个问题
- 1 回答
- 0 关注
- 142 浏览
添加回答
举报
0/150
提交
取消