Join our Newsletter — 33% off our NHI Course

How can security teams tell when test caching is hiding a dependency problem?

Watch for tests that discover inputs at runtime, call out to services, or change behaviour when fixture files are added or altered. If a relevant input changes and the result still reports cached, the cache key is incomplete. That is the strongest signal that the test is not modelling its dependency set correctly.

When cached tests are telling you the wrong story

Test caching is a performance feature, but it becomes misleading when the cache key no longer represents everything the test depends on. If a test reads inputs dynamically, reaches outside its fixture set, or starts passing and failing based on file changes the cache did not notice, the cache is masking dependency drift rather than speeding up a stable test.

The practical question is not whether caching is enabled, but whether the cached result is still grounded in the same inputs, files, and runtime context. When the observed behaviour changes after a dependency changes, yet the runner still reuses the old result, the test is no longer a trustworthy signal.

What dependency drift looks like in practice

A healthy cached test has a deterministic dependency set: the same code, the same fixtures, the same environment, and the same outputs. Problems start when tests discover inputs at runtime, pull values from the network or a database, or depend on implicit filesystem state that was never part of the cache fingerprint. In those cases, the cache may be reusing a result from a different world than the one the test is now observing.

Small fixture edits are especially useful as a diagnostic. If you add, remove, or alter a relevant fixture file and the test still reports a cache hit, that is evidence the cache key is incomplete. The test may be correct by accident today, but it is not describing its full dependency set.

One useful external reference for treating this as a broader software integrity problem is OpenSSF, because the same discipline applies to dependency awareness, reproducibility, and trust in build and test artefacts.

How to prove the cache is hiding a missing dependency

The strongest proof is a controlled change test. Change one input that should matter, then observe whether the test result recomputes. If the behaviour changes but the cache does not, the dependency was real and the cache key did not include it. If the cache invalidates on a harmless change but not on a relevant one, the cache key is both noisy and incomplete, which usually means the dependency model is inconsistent.

Look for three warning patterns: tests that reach out to live services, tests that read generated or shared files without declaring them, and tests whose result depends on ordering, time, or environment variables that are not captured in the cache key. Those are all signs that the test is using hidden state as part of its input.

A broader supply-chain perspective is useful here too. The LiteLLM PyPI package breach is a reminder that dependency assumptions matter when code consumes external inputs or packages, because trust breaks when the system does not accurately model what it depends on.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS, SLSA, NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP ASVS V15 — Secure Coding and Architecture Test determinism and declared dependencies are part of secure, reliable software architecture.
Recommendation — Model tests so all meaningful inputs are explicit and reproducible.
SLSA Supply Chain Integrity Cache correctness depends on trustworthy, reproducible artefacts and dependency tracking.
Recommendation — Track provenance and inputs so cached results stay tied to the right artefacts.
NIST CSF 2.0 PR.DS-01 — Data-at-rest is protected Cached test results and fixtures are stored artefacts whose integrity affects decision quality.
Recommendation — Protect cached artefacts and their inputs from unintended modification.
CIS Controls v8 CIS-7 — Continuous Vulnerability Management Recurring test failure patterns and changing dependencies need continuous review and validation.
Recommendation — Continuously validate test dependencies and rerun checks when inputs change.

Practitioner Guidance

What to verify: Confirm that every input the test can observe is represented in the cache key, including fixtures, generated files, environment variables, and service responses if they are part of the test contract. If you cannot name the dependency, the cache probably cannot key it either.

Decision rule: If changing a file, fixture, or upstream input changes the expected result, treat any persistent cache hit as a defect in the test design, not a performance win. In that case, either declare the dependency explicitly or stop caching that test path.

What practitioners underestimate: Hidden dependencies are often introduced by convenience, not by design. A test can look deterministic while quietly depending on runtime discovery, shared state, or environment drift, which means cached success is validating the cache, not the test.

Practitioner takeaway: A reliable cache only works when the test’s dependency set is explicit and stable; if a meaningful input can change without invalidating the cache, the test is under-specified.