I have a little service written in Go. I am already testing it with httptest
and others, but I am mocking the database, etc ....
What I would like to do:
- Run the same server that I use when working with an empty database
- Run tests using HTTP
- Get coverage for these tests.
The empty part of the database is not a problem, since I made everything custom using environment variables.
Making requests to it is not a problem either, as this is just standard Go code ...
The problem is this: I do not know how to start the server in such a way that I can measure its coverage (and its subpackages). In addition, the main server code is inside the main
function ... I donβt even know if I can call it from another place (I tried the standard path, but not with reflection, etc.).
I kind of use Go, so I could say stupid things.
source share