donglaoping9702 2018-12-11 08:50
浏览 43

银杏到cobertura和JUnit

I am using Shippable as my CI and my project is based on Go 1.11. All the unit tests are written in BDD style using Ginkgo and Gomega. In my test pipeline, I have something like:

gocov test ./... | gocov-xml > shippable/codecoverage/coverage.xml
go test -v ./... | go-junit-report > shippable/testresults/junitresults.xml

This will create the coverage file in Cobertura format and unit test report in JUnit format.

In my project, we have multiple test suites. I am planning to use Ginkgo CLI to perform coverage and unit test instead of gocov and go test. Something like:

ginkgo -r -cover -outputdir=./shippable/codecoverage/ -coverprofile=coverage.txt
ginkgo -r -focus="\[Unit\]" -outputdir=./shippable/testresults/ -coverprofile=unit.txt

Now the problem is that I am unable to convert the coverage.txt file to equivalent Cobertura format XML file (which shippable will require) and unit.txt file to equivalent JUnit XML file.

I've seen how to generate the JUnit file from a test suite but in my project, we have multiple test suite, which will result in multiple JUnit files, which I don't want.

Any idea, how can I convert and use them?

  • 写回答

1条回答 默认 最新

  • dongyan6910 2018-12-11 11:22
    关注

    To create the Cobertura format:

    Nevermind, figured out myself.

    Generate the cover using covermode as set

    ginkgo -r -cover -covermode=set -outputdir=shippable/codecoverage/ -coverprofile=coverage.out

    Now, we need to remove duplicate entries of mode: set

    awk '!seen[$0]++' shippable/codecoverage/coverage.out > shippable/codecoverage/coverage-fix.out

    Finally, convert to Cobertura

    bash gocov convert shippable/codecoverage/coverage-fix.out | gocov-xml > shippable/codecoverage/coverage.xml

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料