Code coverage for Go integration tests
go.dev
go.dev
Here's an example of the build step: https://github.com/multiprocessio/datastation/blob/main/runn....
And here's how I'd analyze coverage after using the binary: https://github.com/multiprocessio/datastation/blob/main/runn.... This analysis actually combined both unit test coverage files with integration test coverage so it gave a pretty good overall indication of code paths covered by any tests.
I can't remember where I found this technique but it's been around for a while.
This new option is the same thing but a way to `go build` with `-cover` instead of `go test -cover -o $out`? Do I have that right?
Another example of doing this from 2019: https://stackoverflow.com/a/55640874/1507139. I'm sure I learned about this from somebody's blog but I can't remember where.
Anyway, very happy to see the team ship first class support for it. It immediately made coverage support in testscript much more natural, too. https://github.com/rogpeppe/go-internal/pull/201
If I recall correctly, there's zero configuration needed for Go projects. You can be up and running in minutes.
I think Codecov is free for open source projects and paid for private repos, someone more knowledgeable can chime in.
If you want to methodically measure integration test coverage it seems more valuable to enumerate all your critical features or user flows and attribute test cases to them.
Integration testing is where most testing cycles fail. It’s also more difficult for the developer because now they need an emulator, a container, or some sandbox to test the integration.
Feature testing is one thing but I’d like to know if the foundation works, that the plumbing is there.
https://github.com/pldubouilh/rust-coverage-integration-test
Let me describe a scenario:
Let's say you just inherited some service that is already running in production but it don't have a great documentation nor a good test suite. To make matters worse you don't really know how this service is being used and what are the critical paths inside it.
What I'm thinking is if it would be possible to use this feature to collect some real world usage data for this application. And this data could give you a better understanding about what is actually important in the service.
For APIs we already have a part of this data, as most server in Go have the number of requests for each endpoint. But I think in many cases a more granular data could be really helpful.
Yes, I know that the number of times some function was called isn't a reliable indicator of the importance of said function. But it should be better than nothing.
And I also know that something like this would have a negative performance effect that would not be acceptable for some situations.
Does anyone have recommendations of tooling to generally help instrument testing CLI tools? Hopefully better than what I’ve done thus far which is basically a shell script of
./mybinary <<< $INPUT > output.txt 2> error.txt
diff expected-output.txt output.txt
diff expected-error.txt error.txtI am curious if the overhead of this feature allows for running it in production for some time, let’s say a day.