This prompt is for test architects and QA leads who need to quantify the balance between positive and negative test coverage across a system or feature area. The job-to-be-done is producing a structured comparison report that identifies over-tested happy paths and under-tested error, exception, and failure scenarios. Use it when you have a list of existing test cases and a set of functional paths or requirements, and you need evidence to justify rebalancing test effort toward resilience and error handling. The ideal user has access to test case titles, descriptions, or tags, and understands the system's expected behavior under both normal and failure conditions.
Prompt
Happy-Path vs Sad-Path Coverage Comparison Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Happy-Path vs Sad-Path Coverage Comparison Prompt.
Do not use this prompt when you lack a defined set of functional paths to compare against. If your test cases are not categorized or you cannot distinguish happy-path from sad-path scenarios with reasonable confidence, the output will be speculative rather than actionable. This prompt is also not a substitute for a full risk-based test assessment—it focuses narrowly on the happy/sad ratio and does not evaluate security, performance, or compliance coverage. For regulated domains, always pair the output with a human review step and cross-reference against your traceability matrix before making resourcing decisions.
Before running this prompt, gather your test case inventory and a list of functional paths or user stories. The prompt expects you to provide both, along with a classification schema for what counts as a happy path versus a sad path in your context. After receiving the comparison report, validate the path classifications against your own domain knowledge—models can misclassify ambiguous scenarios. Use the coverage ratio scoring to prioritize new test creation, but do not treat the ratio alone as a quality gate. The next step is typically feeding the identified gaps into a test case generation workflow or a risk-based test planning session.
Use Case Fit
Where the Happy-Path vs Sad-Path Coverage Comparison Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your current test architecture review.
Good Fit: Structured Test Repositories
Use when: you have test cases in a test management system with clear pass/fail outcomes and linked requirements. Guardrail: the prompt needs explicit path classification rules to distinguish happy-path from sad-path tests reliably.
Good Fit: Pre-Release Coverage Reviews
Use when: you are evaluating coverage balance before a release and need a data-driven ratio of positive to negative tests. Guardrail: pair the prompt output with a manual review of any test classified as ambiguous or mixed-path.
Bad Fit: Exploratory or Unscripted Testing
Avoid when: your test evidence is session notes, chat logs, or ad-hoc bug reports without structured test case records. Guardrail: the prompt requires structured inputs; unstructured evidence will produce unreliable path classifications and false coverage ratios.
Bad Fit: Real-Time CI/CD Gating
Avoid when: you need a sub-second coverage decision in a deployment pipeline. Guardrail: this prompt is designed for periodic analysis, not real-time gating. Use a pre-computed coverage ratio threshold instead of calling the model on every build.
Required Inputs
Must provide: a list of test cases with titles, steps, expected results, and linked requirements or user stories. Guardrail: missing requirement links will prevent the prompt from validating whether a test is truly happy-path or misclassified. Validate input completeness before running.
Operational Risk: Over-Reliance on Ratios
Risk: teams may treat the coverage ratio as a target rather than a diagnostic signal, leading to test bloat or box-checking. Guardrail: always interpret the ratio alongside risk-based priorities. A 50/50 split is not inherently correct for every system.
Copy-Ready Prompt Template
A reusable prompt template for comparing happy-path and sad-path test coverage, producing a structured gap report with coverage ratios and prioritization.
This template is designed for test architects and QA leads who need to evaluate the balance between positive and negative test coverage across a feature, module, or system. It accepts a list of existing test cases and their classifications, then produces a comparison report that identifies over-tested happy paths and under-tested error, exception, and failure scenarios. The prompt is structured to enforce path classification validation and coverage ratio scoring, making it suitable for risk-based test planning and compliance review workflows. Before using this template, ensure you have a reasonably complete inventory of test cases with their intended path types—this prompt diagnoses coverage balance, not test case completeness.
textYou are a test architect evaluating the balance between happy-path and sad-path test coverage for a software system. Your task is to analyze the provided test cases, classify each as happy-path or sad-path, and produce a structured comparison report identifying coverage gaps. ## INPUT Test cases with descriptions and any existing path classifications: [TEST_CASES] Feature or module context: [FEATURE_CONTEXT] ## CLASSIFICATION RULES - Happy-path: Tests where all inputs are valid, preconditions are met, and the system completes its primary intended behavior without errors. - Sad-path: Tests involving invalid inputs, missing preconditions, authentication failures, authorization denials, resource unavailability, timeouts, malformed data, boundary violations, or explicit error/exception handling. - If a test case cannot be confidently classified, flag it as [UNCERTAIN] and explain why. ## OUTPUT SCHEMA Produce a JSON object with the following structure: { "summary": { "total_tests": <number>, "happy_path_count": <number>, "sad_path_count": <number>, "uncertain_count": <number>, "happy_path_percentage": <number>, "sad_path_percentage": <number>, "coverage_ratio": "<happy>:<sad>" }, "classification_review": [ { "test_id": "<string>", "description": "<string>", "original_classification": "<string or null>", "assigned_classification": "happy|sad|uncertain", "rationale": "<string>" } ], "gap_analysis": { "over_tested_happy_paths": ["<patterns or scenarios with excessive happy-path coverage>"], "under_tested_sad_paths": [ { "scenario": "<description of missing error/exception scenario>", "risk_level": "high|medium|low", "suggested_test_count": <number> } ], "missing_error_categories": ["<error types with zero coverage>"] }, "recommendations": [ { "action": "<string>", "priority": "high|medium|low", "rationale": "<string>" } ] } ## CONSTRAINTS - Classify every test case individually; do not assume classifications from test names alone. - If original classifications are provided, note discrepancies between original and assigned classifications in the rationale field. - Flag any test case that appears to test both happy and sad paths as uncertain and recommend splitting it. - A healthy coverage ratio target is between 40:60 and 60:40 (happy:sad). Ratios outside this range should trigger high-priority recommendations. - For regulated or safety-critical systems, sad-path coverage below 40% must be flagged as a critical gap. ## EVALUATION CRITERIA A valid output must: 1. Classify 100% of provided test cases. 2. Provide specific, actionable gap descriptions, not generic advice. 3. Include risk levels for all identified gaps. 4. Justify any recommendation to add tests with a concrete scenario description. ## RISK LEVEL [RISK_LEVEL] // Use "standard" for most applications; use "safety-critical" for medical, aviation, industrial control, or financial settlement systems to enforce stricter ratio requirements.
To adapt this template, replace [TEST_CASES] with your actual test inventory—ideally exported from your test management system with IDs and descriptions. The [FEATURE_CONTEXT] placeholder should contain a brief description of the feature or module under analysis to ground the classification decisions. Set [RISK_LEVEL] to "safety-critical" when analyzing systems where failures can cause harm, financial loss, or regulatory violations; this tightens the acceptable ratio range and escalates gap severity. For production use, validate the output JSON against the schema before ingestion, and consider running this analysis per-release as part of your quality gate checks. If your test cases lack descriptions detailed enough for classification, run a test documentation improvement pass first—this prompt cannot compensate for vague or missing test case metadata.
Prompt Variables
Inputs required for the Happy-Path vs Sad-Path Coverage Comparison Prompt. Each placeholder must be populated before execution to ensure reliable path classification and coverage ratio scoring.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TEST_CATALOG] | Structured list of existing test cases with IDs, titles, steps, and expected results | JSON array of test case objects exported from TestRail or Xray | Schema check: each object must have id, title, steps, expected_result fields. Null not allowed. |
[REQUIREMENT_SET] | Requirements, user stories, or acceptance criteria the tests should cover | Jira user story export with acceptance criteria or a PRD section | Schema check: each item must have id and description. Null not allowed. Minimum 5 requirements recommended for meaningful comparison. |
[PATH_CLASSIFICATION_RULES] | Definitions for classifying a test as happy-path, sad-path, error-path, or boundary-path | Happy-path: valid inputs, expected success. Sad-path: invalid inputs, expected handled errors. Error-path: unhandled exceptions. Boundary-path: edge values at limits. | Parse check: must contain at least 3 classification categories with definitions. Null not allowed. Retry if classifications are ambiguous. |
[COVERAGE_THRESHOLD] | Minimum acceptable ratio of sad-path to happy-path tests, expressed as a percentage | 0.40 meaning 40% sad-path coverage relative to happy-path | Parse check: must be a float between 0.0 and 1.0. Default 0.30 if not specified. Null allowed, triggers default. |
[RISK_WEIGHT_MAP] | Optional mapping of requirement risk levels to coverage importance multipliers | {"critical": 3.0, "high": 2.0, "medium": 1.0, "low": 0.5} | Schema check: must be a JSON object with string keys and numeric values. Null allowed. If null, uniform weighting applied. |
[OUTPUT_SCHEMA] | Expected structure for the comparison report output | JSON schema with fields: happy_path_count, sad_path_count, error_path_count, boundary_path_count, coverage_ratio, gaps[], over_tested[], recommendations[] | Schema check: must be valid JSON Schema. Null not allowed. Retry if output does not conform. |
[EXCLUSION_FILTERS] | Optional rules for excluding certain test cases from analysis | Exclude tests tagged as deprecated, flaky, or manual-only | Parse check: must be a list of exclusion conditions. Null allowed. If null, all tests included. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for path classification before flagging for human review | 0.85 meaning classifications below 85% confidence are marked uncertain | Parse check: must be a float between 0.0 and 1.0. Default 0.80. Null allowed, triggers default. |
Implementation Harness Notes
How to wire the Happy-Path vs Sad-Path Coverage Comparison Prompt into a test analysis pipeline with validation, scoring, and human review gates.
This prompt is designed to operate as a batch analysis step within a QA intelligence pipeline, not as a real-time chat interaction. The typical integration pattern involves feeding the prompt a structured payload containing a list of test cases and their associated requirements, then receiving a scored comparison report. Because the output includes coverage ratios and gap classifications that may influence release decisions, the implementation must include automated validation of the output schema, scoring consistency checks, and a human review gate before findings are committed to a test management system like TestRail, Xray, or Azure Test Plans.
To wire this into an application, construct the input payload by joining data from your test case repository and requirements store. The [TEST_CASES] placeholder expects an array of objects with id, title, steps, and linked_requirements fields. The [REQUIREMENTS] placeholder expects objects with id, description, and acceptance_criteria. Before calling the model, run a pre-validation step to ensure every test case has a non-empty steps array and every requirement has at least one acceptance criterion. After receiving the model response, validate the output against the expected schema: a JSON object containing coverage_summary, happy_path_tests, sad_path_tests, gap_analysis, and recommendations arrays. Reject any response where the coverage_ratio field is not a number between 0 and 1, or where gap_analysis entries lack a severity field. Log the raw prompt, response, and validation result for auditability.
For high-stakes releases, implement a dual-model verification pattern: send the same input to two different models (e.g., Claude and GPT-4) and compare the coverage ratios and top-5 gap findings. If the ratios diverge by more than 15% or the gap lists disagree on high-severity items, flag the analysis for mandatory human review. Store the comparison delta alongside the final report. Avoid using this prompt on test suites exceeding 200 test cases in a single call—chunk large suites by functional area and aggregate the results in a post-processing step. The next step after implementation is to build a regression test that runs this prompt against a known golden dataset with pre-labeled happy-path and sad-path classifications to measure classification accuracy before trusting it on production test suites.
Expected Output Contract
Fields, types, and validation rules for the Happy-Path vs Sad-Path Coverage Comparison Report. Use this contract to parse, validate, and store the model output before downstream consumption.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
report_metadata | Object | Must contain | |
coverage_summary.total_test_cases | Integer | Must be >= 0 and equal to sum of happy_path_count + sad_path_count + unclassified_count. | |
coverage_summary.happy_path_ratio | Float (0.0-1.0) | Must equal happy_path_count / total_test_cases. Validate with tolerance of 0.01. | |
coverage_summary.sad_path_ratio | Float (0.0-1.0) | Must equal sad_path_count / total_test_cases. Validate with tolerance of 0.01. | |
path_classifications[].test_case_id | String | Must match a test case identifier from the input source. Non-empty. Schema check: regex [A-Za-z0-9_-]+. | |
path_classifications[].classification | Enum: HAPPY_PATH | SAD_PATH | UNCLASSIFIED | Strict enum match. Reject any value not in the set. UNCLASSIFIED allowed only when confidence < threshold. | |
path_classifications[].classification_confidence | Float (0.0-1.0) | Must be >= 0.0 and <= 1.0. If < 0.7, classification must be UNCLASSIFIED. Trigger human review if confidence < 0.9 for HAPPY_PATH or SAD_PATH. | |
gap_analysis.over_tested_happy_paths[] | Array of test_case_id strings | Each ID must exist in path_classifications with classification HAPPY_PATH. Null allowed if no over-tested paths found. | |
gap_analysis.under_tested_sad_paths[] | Array of objects with | Each | |
recommendations[].action | String | Must be one of: ADD_SAD_PATH_TEST, DEPRIORITIZE_HAPPY_PATH, REBALANCE_SUITE, REVIEW_UNCLASSIFIED. Non-empty. | |
recommendations[].target_test_ids | Array of strings | Each ID must reference an existing test_case_id from path_classifications. Null allowed for ADD_SAD_PATH_TEST actions. |
Common Failure Modes
What breaks first when comparing happy-path and sad-path coverage, and how to guard against it.
Happy-Path Over-Indexing
What to watch: The model classifies every test as a happy-path variant because the prompt lacks explicit sad-path definitions. Error paths, timeout scenarios, and null-input cases get labeled as positive coverage. Guardrail: Provide explicit sad-path categories in the prompt schema—include error codes, exception types, boundary violations, and resource exhaustion as required classification labels.
Coverage Ratio Inflation
What to watch: The model reports a balanced ratio by miscounting parameterized happy-path variants as distinct sad-path tests. A single login success test with 20 data rows gets counted as 20 coverage points. Guardrail: Require the prompt to count unique scenario types, not test instances. Add a deduplication step that groups tests by scenario class before computing ratios.
Missing Error Propagation Paths
What to watch: The analysis identifies direct error returns but misses transitive failure paths—when Service A fails and Service B propagates the error without handling it. These gaps hide cascading failure risks. Guardrail: Include dependency graph context in the prompt. Require the model to trace error propagation across service boundaries, not just entry-point error handling.
Undefined Sad-Path Severity Thresholds
What to watch: The model treats a missing optional field with the same severity as an authentication bypass. Coverage scoring becomes meaningless because all gaps carry equal weight. Guardrail: Define severity tiers in the prompt—critical, high, medium, low—with explicit criteria for each. Require the output to assign severity to every identified gap.
Test Artifact Parsing Failures
What to watch: The model misinterprets test names, comments, or assertion messages as coverage evidence. A test named test_error_handling that only checks a 200 response gets classified as sad-path coverage. Guardrail: Require the prompt to analyze assertion logic, not test metadata. Add a validation step that checks whether assertions actually verify error conditions before counting coverage.
Context Window Truncation
What to watch: Large test suites exceed the context window, causing the model to analyze only the first N test cases. Coverage gaps in truncated portions go unreported without any indication of incomplete analysis. Guardrail: Chunk test suites by functional area and run the prompt per chunk. Require the output to include an analysis_completeness flag and list which test files were processed.
Evaluation Rubric
Criteria for evaluating the Happy-Path vs Sad-Path Coverage Comparison Prompt output before integrating it into a QA governance workflow or release gate.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Path classification accuracy | ≥95% of test cases correctly classified as happy-path or sad-path when spot-checked against requirement intent | Misclassification rate >5% in sample; error paths labeled as happy-path or vice versa | Manual audit of 50 randomly sampled classifications against source requirements |
Coverage ratio calculation | Happy-path:sad-path ratio computed correctly with explicit formula shown; denominator and numerator match classified counts | Ratio inverted, missing, or inconsistent with raw classification counts | Automated schema check: ratio field is numeric, matches (happy_count / sad_count) from output |
Gap identification completeness | All requirement areas with zero sad-path tests are flagged; at least one suggested test per gap | Gaps table empty when sad-path coverage is demonstrably incomplete; suggested tests missing for flagged gaps | Cross-reference gap list against requirement-to-test traceability matrix; verify each gap has ≥1 suggestion |
Risk prioritization logic | Gaps sorted by risk score combining requirement criticality and coverage absence; top 3 gaps align with business risk register | Low-risk cosmetic gaps ranked above auth or data-loss gaps; risk scores not explained | Compare top-5 gap ranking against known risk register; check that risk_score field uses defined formula |
Output schema compliance | All required fields present: classifications[], coverage_ratio, gaps[], suggestions[], risk_summary; no extra top-level keys | Missing required fields; null values where arrays expected; malformed JSON | JSON Schema validation against expected output contract; reject on schema violation |
Source grounding and traceability | Every gap and suggestion references at least one requirement ID or user story ID from input | Suggestions or gaps with no source reference; fabricated requirement IDs not present in input | Parse all requirement_id fields in output; verify each exists in input requirement list |
Over-tested happy-path detection | Flags happy-path tests exceeding 3x the mean happy-path coverage per requirement area with consolidation suggestion | No over-testing flags when happy-path tests clearly dominate; flags without supporting count evidence | Check over_tested[] array; verify each entry includes test_count, mean_count, and consolidation rationale |
Edge-case coverage within sad-path | Sad-path analysis distinguishes error paths from boundary-condition paths; both subcategories assessed separately | All sad-paths treated as uniform; no boundary vs. exception distinction; edge cases merged into generic error bucket | Parse sad_path_subcategories field; verify boundary_conditions and error_paths are separate arrays with distinct entries |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a lightweight classification schema. Replace [PATH_CLASSIFICATION_SCHEMA] with a simple two-category enum: happy_path and sad_path. Drop the coverage ratio scoring and focus on producing a plain list of over-tested and under-tested paths.
Prompt snippet
codeClassify each test case in [TEST_CASE_LIST] as either "happy_path" or "sad_path". For each requirement in [REQUIREMENT_LIST], count how many happy-path and sad-path tests exist. Flag any requirement with zero sad-path tests.
Watch for
- Ambiguous path classification when a test exercises both happy and sad sub-steps
- No validation that the input test list is complete or correctly mapped to requirements
- Over-flagging when requirements are inherently happy-path-only (e.g., display formatting)

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us