当我使用测试Go Project代码的Java语言运行测试时,如何获取代码覆盖率报告?

I have a very special requirement in integration testing in go. In the past few days I have read through many blogs but I am unable to get the solution for this problem. Please share me if you have done anything below.

Infra details:

  • Having Go project up and running
  • Having my automation framework written in JAVA

My Exact requirement is:

  1. I have to instrument the Go code and make the go code running
  2. Execute my java automation code
  3. Stop the Go code / get the code coverage report from Go

Thanks in advance!!

  1. write your Go code as a test, in a file ending_test in the package directory

  2. run the Go test as $ go test --coverprofile outfile . If it needs to run as a server then add some code to time it out

  3. run your additional Java code

  4. wait for the timeout

  5. use a command like $ go tool cover -html=outfile -o cover.html to see the coverage analysis