我的 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/[email protected]
- 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/[email protected]
和
go install github.com/jstemmer/go-junit-report/v2@934b104ddd2
這解決了這個問題
- 1 回答
- 0 關注
- 128 瀏覽
添加回答
舉報
0/150
提交
取消