Parallel functional tests and per-test coverage: what stays exact, what is shared
By Melih Sakarya · Published · 5 min read

Short answer
Functional suites run in parallel to fit into CI, and every parallel test hits the same long-running services. Line counters cannot say which of two simultaneous requests ran a line. Here is what CoverOps keeps exact anyway, what it shares and labels, how each agent draws the line, and how to keep the shared part small.
Short answer: when parallel tests send requests to the same service process at the same time, no line counter can tell whose request ran which line, because the counters belong to the whole process. CoverOps does not pretend otherwise. It keeps everything that can be exact exact: each test's requests, endpoints, services and methods come from per-request traces, which never mix. For lines, while tests overlap in one process, every test in that span gets all of the span's lines and the overlap is recorded, so no test ever loses a line it ran and you can see which tests' lines may include someone else's. The .NET agent and PHP do not share at all. Run and service coverage are unaffected.
Why the problem exists
An end-to-end suite of a few hundred tests runs in parallel workers, or it does not fit into a pipeline. All those workers talk to the same orders, pricing and inventory processes. Inside each process, coverage is a set of counters: JaCoCo-style probes on the JVM, V8's counters in Node.js, coverage.py's data in Python, the coverage counters in a Go binary. A request that runs a line increments its counter. Two requests that run at the same time increment the same counters, and a counter has no idea which request it was.
Traces are different. A trace is recorded per request: the agent knows which request entered which method, and the request carries the test's name. So the shape of the problem is precise: which code paths a test took is always knowable, which lines it ran is only knowable while it has the process to itself.
What CoverOps does
Agents cut coverage into windows by test activity. While only one test's traffic is in a process, the window is that test's alone and its lines are exact. While several tests' traffic overlaps, the window is shared:
time ─────────────────────────────────────────────▶
test A ▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇
test B ▇▇▇▇▇▇▇▇▇▇▇
lines A only A + B shared, overlap=1 each
- No test loses a line. Every test that had traffic in a shared window is credited with all of the window's lines. A footprint may hold lines another test ran; it never misses one of its own.
- The overlap is recorded. Agents send
overlap: nwith each test, the number of other tests that shared its window, and the server keeps the highest report per test. - It is shown where you read the result. The test's detail on the run page says it ran at the same time as N other tests against the same service, so these lines may include theirs, and that the request flow above is this test's alone. The footprint API returns the same number as
coverage.shared_with.
To check a test from a script, ask for its footprint and read the field:
curl -sG "$COVERAGEOPS_ENDPOINT/v1/agent/runs/footprint" \
-H "Authorization: Bearer $COVERAGEOPS_TOKEN" \
--data-urlencode "run_key=$RUN_KEY" \
--data-urlencode "name=checkout::buys a desk" | jq '.coverage.shared_with, .summary'
Zero means the test's lines are its own. A higher value is the largest number of other tests that shared a window with it. The services, endpoints and methods in the summary are exact either way.
What each agent does
- Java and Node.js read the probes or V8's counters at each window edge.
- Python switches coverage.py's dynamic context at each window edge and labels the context with its participants, so a test that joins late is not credited with what ran before its first request.
- Go dumps the coverage counters in process at each window edge and keeps the ones that moved; the binary needs
-covermode=atomic. - .NET records lines per request through the request's async context. Parallel tests are told apart exactly.
- PHP serves each request in its own process, so nothing is shared.
The same rules apply when tests run inside the test runner's own process. JUnit 5 and TestNG parallel modes share windows in one JVM, while Surefire forks and Gradle's parallel forks are separate JVMs and exact. pytest-xdist workers are processes, so they are exact. Go's t.Parallel tests share while sequential tests stay exact. The .NET agent asks the test framework which test the running code belongs to, so parallel NUnit, xUnit and MSTest tests are exact. Jest and Vitest test.concurrent tests get no footprint of their own.
What sharing changes, and what it does not
- Run and service coverage: unchanged. They are merged totals, and a line any test ran is covered however many tests were running.
- The changed-code gate: unchanged. It reads the run's merged coverage, not per-test lines.
- Requests, endpoints, services, methods per test: exact, always.
- Test selection and Impact: a changed line may select a few more tests than strictly needed, never fewer. That is the safe direction: a shared window can make a test run that did not need to, but it cannot make a test be skipped that should have run.
- The line view: "N tests touch this" on a line can include tests that shared a window with the one that really ran it.
How to keep the shared part small
Sharing only happens when tests reach the same process at the same moment, so you control how much of it there is.
- Look before you change anything. Open a few tests on the run page and read their overlap note. How much tests share depends on how often their requests actually reach one process at the same moment, not only on the number of workers.
- Give workers their own processes where exact lines matter. Overlap is per process: tests whose requests reach different processes at the same time do not share a window.
- Run the few tests you need exact lines for one at a time, for example the tests whose footprints drive selection for a critical service, and keep the rest parallel.
- For in-process tests, prefer process-level parallelism: Surefire forks, Gradle parallel forks, pytest-xdist.
Whatever you choose, the safe side holds: you never get a footprint that is missing a line its test ran.
Limits
- Lines are shared, not split, while tests overlap in one process. CoverOps does not estimate a split.
- A hop that does not carry the test's context has its coverage in the run but under no test, parallel or not.
- Code that runs once per process, such as a static initialiser or a cached context, is credited to the test that ran it first.
- Go needs
-covermode=atomicfor per-test windows.
This post is part of the series that starts with functional test coverage in distributed systems. For what a per-test footprint contains and where to read it, see per-test coverage across microservices; for how footprints decide what to skip, the test selection guide. The concepts guide covers parallel tests, and the integration test coverage page has the summary.
Related posts
- Changed-code coverage as a merge gate when a change spans services
Diff coverage from one repository's unit tests cannot see that the new lines in the inventory consumer only run when an end-to-end test places an order. Here is how to gate a merge on the changed lines your functional tests actually ran, in every service, and how to keep a service that did not run from quietly passing the gate.
- Bir değişiklik birden fazla servise dokunduğunda merge gate olarak changed-code coverage
Tek bir repository'nin unit testlerinden gelen diff coverage, inventory consumer'ındaki yeni satırların yalnızca bir end-to-end test sipariş verdiğinde çalıştığını göremez. Merge'ü, fonksiyonel testlerinizin her serviste gerçekten çalıştırdığı değişen satırlara bağlamayı ve hiç çalışmamış bir servisin kapıdan sessizce geçmesini önlemeyi anlatıyoruz.
- Is every replica reporting? Monitoring coverage agents across a fleet
A coverage number is only as complete as the processes behind it. When a service runs as five pods in two environments, you need to see that all five are reporting before you trust the run. Here is how the CoverOps live fleet shows every replica, how replicas merge in a run, and what to check after a rollout.