custom coverage report

120 views
Skip to first unread message

Vasiliy Tolstov

unread,
Aug 20, 2023, 10:29:47 AM8/20/23
to golan...@googlegroups.com
Hi. I have service centric tests - so i want to test not each function
inside application, but only it handlers (defined via protobuf)
Also i have custom framework that runs each test like - start grpc
server, and call it via predefined json based files, and compare
results.
I want to measure coverage , but don't understand how to do that?
Is that possible to have another way to measure handlers coverage in
case of service defined via protobuf?

--
Vasiliy Tolstov,
e-mail: v.to...@selfip.ru

Vasiliy Tolstov

unread,
Aug 24, 2023, 5:13:32 AM8/24/23
to Vasiliy Tolstov, golan...@googlegroups.com
Anybody knows golang package that can write cover files in desired format?

вс, 20 авг. 2023 г. в 17:28, Vasiliy Tolstov <v.to...@selfip.ru>:

Jan

unread,
Aug 24, 2023, 4:42:43 PM8/24/23
to golang-nuts
hey Vasiliy, I'm not sure I understood your requirements, but let me take a stab at it.

By handlers of the protobuf I imagine you refer to those stubs generated by `protoc`, for the gRPCs. Is it correct ? 

They have well defined names/packages that can easily be filtered (grep?) from the the usual function coverage report you get from `go tool covdata func ...`. 
After this filtering, you could take an average, in whichever way you feel appropriate. Would this work for your need ?

Btw, I don't know of a golang package to output cover files ... would the command line tools work ? (`go tool covdata` or for instance `go tool cover --to=HTML`)

cheers!

ps.: Just in case it helps:

* To write the coverage information in text format, I suppose the original blog post still works (it's from 2013) for unit tests.
* For integration tests (e.g: when the test executes the program for which you want coverage) + unit tests together, here is one example: https://github.com/janpfeifer/gonb/blob/main/run_coverage.sh 
Reply all
Reply to author
Forward
0 new messages