Don’t Worship “End-to-End Testing” in AI Delivery: Why “Intermediate Assertions + Boundary Sampling” Is the Quality Baseline
In the actual delivery process at AI Lab, I have observed a very common misconception: many engineers devote most of their energy to so-called “end-to-end (E2E)

Don’t Worship “End-to-End Testing” in AI Delivery: Why “Intermediate Assertions + Boundary Sampling” Is the Quality Baseline
In the actual delivery process at AI Lab, I have observed a very common misconception: many engineers devote most of their energy to so-called “end-to-end (E2E) testing.” They build massive test sets, input a prompt, and then use another LLM (as a judge) to determine whether the output is correct. While this approach is highly efficient during the demo phase, it often exposes significant vulnerabilities when subjected to stress testing in production environments.
The “Survivorship Bias” of E2E Testing
The biggest problem with end-to-end testing is that it operates as a “black box.” When a test case fails, you cannot quickly pinpoint which step went wrong: Did input preprocessing discard key information? Did hallucinations occur in the third step of the Chain of Thought? Or did the final formatting stage produce malformed JSON?
Worse still, due to the stochastic nature of LLMs, passing many E2E tests does not necessarily indicate correct logic; it may simply mean the model got lucky and stumbled upon the right answer this time. This “survivorship bias” creates an illusion of robust quality within the team.
Core Solution: Intermediate Assertions
To establish true determinism, we need to transform the AI delivery process from a “black box” into a “white box.” My core practice is: **enforce structured assertions at every critical transformation node.**
Do not just verify the final result (Input -> Output); instead, verify the entire chain: Input -> State1 -> State2 -> ... -> Output.
For example, in a complex document analysis pipeline:
1. **Node A (Extract Key Entities)** -> Assertion: The number of extracted entities must be >= N, and must include specific keywords.
2. **Node B (Logical Reasoning)** -> Assertion: The reasoning path must reference at least two entities extracted by Node A.
3. **Node C (Generate Conclusion)** -> Assertion: The numerical values in the conclusion must match the intermediate calculation results from Node B.
By adopting this approach, when the system fails, we can instantly identify which “contract” was broken. This shifts AI debugging from “mystical tuning” to systematic engineering troubleshooting.
Boundary Sampling and Stress Distribution
In addition to intermediate assertions, we need to change our sampling strategy. Traditional random sampling fails to cover extreme cases in the long-tail distribution.
In our engineering practice, we employ the **“Boundary Stress Distribution Method”**:
- **Length Boundaries**: Input extremely short (10 characters) and extremely long (30k tokens) documents to observe whether context window truncation causes logical loss.
- **Noise Boundaries**: Randomly insert irrelevant distracting information or malformed garbage data into the input to verify the model’s robustness.
- **Conflict Boundaries**: Provide contradictory instructions (e.g., “Please analyze A in detail,” followed by “Please summarize A in one sentence”) to observe whether the model correctly handles priority conflicts.
Advice for AI Engineers
AI delivery is not about writing prompts; it is about building an engineering system capable of tolerating uncertainty. If you are still relying on a huge `test_cases.json` file and a `gpt-4-judge` to decide whether to go live, you are essentially gambling.
The true baseline for quality should be: **visible intermediate states + strict structured assertions + boundary-covering stress sampling.** This is the only path to turning AI from a “toy” into a “tool.”
Comments
Share your thoughts!
Loading comments…