I created a couple of Rest API based Microservices running of different ports of a server.
Then i wrote a Test code that actually sends a Rest API call over HTTP to serviceA (which in turn calls serviceB), and gets its response, decodes it and compares it against the expected response.
This all works OK, but the test shows 0.0% coverage when i ran it as go test -cover
src/
|--serviceA/
| |--main.go
| |--integration_test.go
|--serviceB/
|--main.go
I manually ran each service.
go run serviceA/main.go // Listens on port X
go run serviceB/main.go // Listens on port Y
My integration_test.go
has a TestFunc()
that literally calls one REST API endpoint of serviceA/main.go
using http.Client{}
and http.NewRequest()
and then examines the response.
Response is as expected but coverage of serviceA
is 0.0%, which should not be the case as it actually sent some data back so multiple lines were executed.
The services A & B are not a lib package so i couldn't use the -coverpkg
cmd as mentioned here
Probably I am looking for tool that can give coverage of a blackbox component/service.