我的 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
守着一只汪
相关分类