Is it possible to create a go (golang) binary that is instrumented for coverage for tests other than unit tests?

huangapple go评论68阅读模式
英文:

Is it possible to create a go (golang) binary that is instrumented for coverage for tests other than unit tests?

问题

我有一些用Ruby/Cucumber编写的测试用例,用于我的Go项目。因此,我无法利用"go test"的覆盖率工具来获取这些测试用例的覆盖率数据(我也有单元测试,并且可以愉快地生成覆盖率数据)。

有没有一种方法可以创建一个带有仪器的Go代码构建,以便我可以为这些非Go测试生成覆盖率数据呢?

英文:

I've got some tests for my go project which are written in ruby/cucumber and I'm therefore unable to take advantage of the "go test"-based coverage tools to get coverage numbers for those tests (I also have unit tests and I'm happily generating coverage numbers for those).

Is there a way to create an instrumented build of go code such that I can generate coverage numbers for those non-go tests?

答案1

得分: 1

不,你需要在GO中编写一个Ruby/Cucumber解释器,编写/调整一个覆盖率测试框架,然后将其与go测试框架集成。只需将传统的Ruby代码重写为Go代码即可:P

英文:

No. You would have to write a ruby/cucumber interpreter in GO, write/adapt a coverage testing framework and then integrate that with the go test framework.
Just rewrite the legacy ruby code in Go Is it possible to create a go (golang) binary that is instrumented for coverage for tests other than unit tests?

答案2

得分: 0

不,但你可以以生成覆盖率 HTML 页面的方式运行 go test。
像这样:

go test -v -coverprofile cover.out ./...
go tool cover -html=cover.out -o cover.html
open cover.html
英文:

NO, but you can run go test in a way that creates coverage html pages.
like this:

go test -v -coverprofile cover.out ./...
go tool cover -html=cover.out -o cover.html
open cover.html

huangapple
  • 本文由 发表于 2014年8月8日 00:57:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/25188128.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定