Integration test coverage
Integration test coverage across every service, test by test
Integration test coverage is the share of your code that integration tests execute. It is hard to collect because that code runs in other processes: services in containers, a staging environment, consumers behind a queue. CoverOps puts an agent in each of those services, ties them to one run by the CI build id, and records which code every test reached.
By the CoverOps team · Last updated
Why teams choose CoverOps for integration test coverage
Per test, across services and queues
Line-level coverage of every service an integration test reaches, attributed to that test across HTTP calls and Kafka and RabbitMQ messages, without code on the Java agent.
No dumps, no report merging
Agents upload while the services run, and every service and runner with the same CI build id lands in one run. A restarted container keeps what it had covered.
A merge gate on the code that changed
Block or flag a pull request when its changed lines were not executed by the tests of its build, with the verdict on the commit status and, on GitHub, a comment listing the lines no test ran.
Skip tests safely, with a reason for every skip
A test is skipped only when its recorded footprint misses every changed line, and the report says why. Observation mode shows what would have been skipped before anything is, and when the change cannot be read in full, everything runs.
Cloud, self-hosted or air-gapped
Use the hosted service in AWS Frankfurt, or run CoverOps in your private cloud, on your own servers or fully offline.
ISO/IEC 27001, 27701 and ISO 9001
Certified to ISO/IEC 27001:2022, ISO/IEC 27701 and ISO 9001. SOC 2 Type 2 is coming soon.
Why integration coverage is harder than unit coverage
Unit-test coverage is collected in the process that runs the tests. Integration tests call code that runs elsewhere, so the usual recipes start a coverage agent in each process under test, stop the process to dump its data, copy the file out of the container, and merge it with the unit-test report. It works for one service. With five, each owned by a different team and started by a different compose file, it rarely survives.
The merged number also hides the useful part. Knowing what share of the order service the suite reached does not tell you which test exercises the refund path, or whether the test that just failed ever reached the code that changed. For that, coverage has to be recorded per test, and the test's identity has to cross every HTTP call and message between services.
CoverOps agents upload as they go, so nothing has to be stopped or copied out, and a service that restarts mid-run keeps what it had covered.
How it works for integration tests
- Start every service the tests call with the CoverOps agent:
-javaagenton the JVM (withtrace=true, which per-test attribution needs there),--requirefor Node.js, or the agent for .NET, Python, Go or PHP. Pass the sameCOVERAGEOPS_RUN_KEYto each container; inside a container the CI build id is not visible on its own. - Let each test name itself on the requests it sends. The JUnit 5 and TestNG integrations give you
currentHeaders(), pytestcoverops.apply_session(…), JestcoverageOpsHeaders(), Robot Framework${COVEROPS_HEADERS}; Postman, k6 or curl send the threeX-CoverageOps-*headers. - The services pass the test context on. The Java agent does it without code for the JDK HTTP clients, Apache HttpClient, OkHttp, Kafka and RabbitMQ; the Node.js agent for
http,httpsandfetch; Go with one transport line; Python, .NET and PHP with the agent's outbound-headers helper. - Tests that run the application in their own process count too: pytest with
--coverops-footprints, Jest and Vitest with coverage on record each test's own lines, added to whatever the services recorded from its traffic.
services:
orders-api:
image: orders-api:test
environment:
JAVA_TOOL_OPTIONS: "-javaagent:/opt/coverageops/agent.jar"
COVERAGEOPS_ENDPOINT: https://api.coverops.ai
COVERAGEOPS_TOKEN: ${COVERAGEOPS_TOKEN}
COVERAGEOPS_INCLUDES: com.yourcompany
COVERAGEOPS_TRACE: "true"
COVERAGEOPS_RUN_KEY: ${CI_PIPELINE_ID}def test_refund(coverops):
api = coverops.apply_session(requests.Session())
order = api.post(f"{base}/orders", json=desk).json()
assert api.post(f"{base}/orders/{order['id']}/refund").okFor a JVM suite that starts the application inside the test JVM (@SpringBootTest and the like), attach the agent to the test JVM through Surefire's argLine. Test classes are left out of the measurement, so the suite does not report its own test code as covered.
What you get
One run for the whole system
Every service and runner that sends the same run key lands in one run: coverage per service with replicas merged, every test's verdict, and the line-by-line source of each file.
Which test reaches which code
For each integration test: the endpoints it called, the services each call crossed (messages included where the context is carried), the methods that ran and the lines it executed.
A changed-code gate
Of the lines a pull request changed, how many did the tests of its build execute? coverageops gate answers in CI and can post the verdict as a commit status on GitHub, GitLab, Azure DevOps or Bitbucket.
Test selection
A test is skipped only when its recorded footprint misses every changed line. New tests, tests without a footprint and recently failed tests always run, and an observation mode shows what would have been skipped before you trust it.
What is measured, and what is not
Measured
- Lines and methods of each service under test, in Java, .NET, Node.js, Python, Go and PHP; branches on Java and Node.js.
- Per test, across HTTP hops and, on Java, Kafka and RabbitMQ messages, wherever the test context is carried.
- In-process tests' own lines with the pytest, Jest and Vitest plugins.
Not measured
- A hop that does not carry the test context: on the Java side Spring WebClient, gRPC, raw
basicConsumeconsumers, Kafka batch listeners and work handed to another thread need a few lines of code. Their coverage still counts for the run, but not under the test. - Databases, stored procedures, brokers and third-party services: only code that runs in a process with an agent.
- Exact per-test lines while tests overlap on the same service process; each overlapping test gets the shared span's lines, never fewer than its own.
Frequently asked questions
How do you measure integration test coverage?
Run the code under test with a coverage agent in its own process, run the integration tests against it, and collect what the agent recorded. With several services you need an agent in each and one run id they all report under; CoverOps adds per-test attribution on top.
Should unit and integration test coverage be combined?
For a gate on changed code, yes: a changed line any test of the build ran is tested. CoverOps reads a build's run as a whole, so in-process footprints from pytest, Jest or Vitest and the services' coverage count together. Keep the per-test view to see which kind of test reaches what.
Can I measure coverage of services running in Docker or Kubernetes?
Yes. The agent goes in the image or is attached through environment variables, and uploads over HTTPS while the service runs, so no file has to be copied out. On Kubernetes a mutating webhook can attach the Java and Node.js agents to annotated pods.
Does the test context follow Kafka and RabbitMQ messages?
On Java, yes, without code: the producer writes it into the record or message headers and the consumer adopts it, so the consumer's code belongs to the test that produced the message. Node.js, Python, Go, .NET and PHP carry it on messages by hand.
What about Go integration tests?
Build the service with -cover -covermode=atomic and add the CoverOps middleware; the agent then reports the running binary's coverage and per-test lines. Unlike the Java and Node.js agents this is a code change.
Keep reading
Related pages
In the documentation
- How CoverOps measures: runs, test context, shared services
- Agents: setup per language
- Quality gates
- Impact: which tests a change touches
The documentation is in English.
Measure your integration suite across services
Bring two services and an API test suite to a demo; we show one run with per-test coverage across both.