- Home
- Skills
- Testing & Debugging
- Bulletproof Test Suite: 100% Line & Branch Coverage Engine
Works with the AI Agents you already use
Bulletproof Test Suite: 100% Line & Branch Coverage Engine
by Tushar
- They mock out critical services into inert placeholders that never throw errors.
$5.99
Bulletproof Test Suite: 100% Line & Branch Coverage Engine
Example session with this skill installed
I have a PaymentProcessor class in TypeScript that handles credit card charges, currency validation, fraud scoring, and retry logic on network timeouts. Write a complete test suite for Vitest that covers 100% of the lines and branches, especially the error paths and retry exhaustion.
- Read your context and instructions
- Compiled the bulletproof test suite
Summary
Analyzed the Abstract Syntax Tree (AST) for PaymentProcessor.ts and mapped 21 distinct branch decision points across input validation, currency allowance, card expiration, idempotency deduplication, fraud score thresholds, and network retry loops. Synthesized a Vitest test suite achieving
100.0% line and branch coverage with zero dead code and zero mock hallucinations.
| Metric | Naive Agent Tests | Bulletproof 100% Test Suite |
|---|---|---|
| Line Coverage | 68% (Misses catch blocks & throws) | 100.0% (Every line exercised) |
| Branch Coverage | 42% (Happy path only) | 100.0% (All 21 AST branches covered) |
| Boundary Perturbation | None (tests single valid number) | 0, negative cents, expired year/month, unsupported currency |
| Failure Mode Testing | Mocks always return 200 OK | Transient socket drops, 503 retry exhaustion, fraud score > 85 |
| Assertion Rigor | toBeDefined() | Exact transaction IDs, retry counters, and error messages |
1. Exhaustive Test Suite (payment_processor.test.ts)
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { PaymentProcessor, ChargeRequest } from './payment_processor';
describe('PaymentProcessor (100% Branch Coverage Suite)', () => {
let mockGateway: { postCharge: any };
let processor: PaymentProcessor;
beforeEach(() => {
mockGateway = { postCharge: vi.fn() };
processor = new PaymentProcessor(mockGateway, 2026, 11);
});
const validReq: ChargeRequest = {
idempotencyKey: 'key_valid_123',
amountCents: 5000,
currency: 'USD',
cardExpiryYear: 2027,
cardExpiryMonth: 12,
fraudRiskScore: 20,
};
it('nominal path: successfully processes valid charge on first attempt', async () => {
mockGateway.postCharge.mockResolvedValueOnce({ status: 'success', txnId: 'txn_999888' });
const res = await processor.processCharge(validReq);
expect(res.status).toBe('succeeded');
expect(res.transactionId).toBe('txn_999888');
expect(res.retriesAttempted).toBe(0);
});
it('boundary validation: throws on zero or negative amount', async () => {
await expect(processor.processCharge({ ...validReq, amountCents: 0 }))
.rejects.toThrow('Invalid amount: 0. Must be strictly positive.');
await expect(processor.processCharge({ ...validReq, amountCents: -500 }))
.rejects.toThrow('Invalid amount: -500. Must be strictly positive.');
});
it('boundary validation: throws on unsupported currency', async () => {
await expect(processor.processCharge({ ...validReq, currency: 'JPY' }))
.rejects.toThrow('Unsupported currency: JPY. Allowed: USD, EUR, GBP');
});
it('card expiration: throws when card expiry is in the past', async () => {
await expect(processor.processCharge({ ...validReq, cardExpiryYear: 2025, cardExpiryMonth: 12 }))
.rejects.toThrow('Payment card is expired.');
});
it('idempotency branch: returns cached duplicate response without duplicate network calls', async () => {
mockGateway.postCharge.mockResolvedValueOnce({ status: 'success', txnId: 'txn_initial' });
await processor.processCharge(validReq);
const duplicate = await processor.processCharge(validReq);
expect(duplicate.transactionId).toBe('idemp_key_valid_123');
expect(mockGateway.postCharge).toHaveBeenCalledTimes(1);
});
it('fraud evaluation: throws when risk score exceeds 85', async () => {
await expect(processor.processCharge({ ...validReq, idempotencyKey: 'key_fraud', fraudRiskScore: 92 }))
.rejects.toThrow('Charge blocked by automated fraud heuristic: risk score 92');
});
it('retry & recovery: succeeds after transient network failure', async () => {
mockGateway.postCharge
.mockRejectedValueOnce(new Error('ETIMEDOUT'))
.mockResolvedValueOnce({ status: 'success', txnId: 'txn_retry_ok' });
const res = await processor.processCharge({ ...validReq, idempotencyKey: 'key_retry' });
expect(res.status).toBe('succeeded');
expect(res.retriesAttempted).toBe(1);
expect(mockGateway.postCharge).toHaveBeenCalledTimes(2);
});
it('retry exhaustion: throws when maxRetries is exceeded', async () => {
mockGateway.postCharge.mockRejectedValue(new Error('503 Service Unavailable'));
await expect(processor.processCharge({ ...validReq, idempotencyKey: 'key_fail' }))
.rejects.toThrow('Payment gateway failed after 3 attempts');
expect(mockGateway.postCharge).toHaveBeenCalledTimes(3);
});
});
2. AST Coverage Audit Verification
$ python scripts/coverage_auditor.py examples/payment_processor.ts --test examples/payment_processor.test.ts
====================================================================
BULLETPROOF 100% TEST COVERAGE & BRANCH AUDIT REPORT
====================================================================
Target: examples/payment_processor.ts
Test File: examples/payment_processor.test.ts
Status: PASSED (Zero Coverage Gaps)
Branch Score: 21 / 21 (100.0%)
Threshold: 100.0%
--------------------------------------------------------------------
File | Branches | Covered | Score
--------------------------------------------------------------------
payment_processor.ts | 21 | 21 | 100.0%
--------------------------------------------------------------------
[OK] 100% branch and condition coverage achieved! All execution paths tested.
====================================================================
Next steps
- Run native coverage in your pipeline:
npx vitest run --coverage --coverage.thresholds.lines=100. - Integrate
scripts/coverage_auditor.pyinto your GitHub Actions PR checks with--min-coverage 100. - If new branches are added to
payment_processor.ts, runcoverage_auditor.py --scaffoldto automatically output stubs for missing vectors.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop Shipping Code With Fake Test Coverage
Standard AI coding agents generate tests that look impressive but test almost nothing:
- They execute only the optimistic happy path.
- They mock out critical services into inert placeholders that never throw errors.
- They miss every fallback branch, catch block, and nullish coalescing operator (
??). - When network errors, negative numbers, or expired sessions hit production, the service crashes because those code paths were never once exercised in a test.
Bulletproof Test Suite changes that. It turns your agent (Claude Code, Cursor, Copilot, Antigravity, or local LLMs) into an SDET that conducts deep AST control-flow audits and synthesizes tests targeting genuine 100% line, branch, and condition coverage.
The 5-Vector Test Generation Swarm
Rather than writing unstructured, ad-hoc test cases, the skill directs your agent through an exhaustive 5-vector inspection:
- Boundary & Input Perturbation: Exercises
0,-1,MAX_SAFE_INTEGER, empty strings, whitespace, Unicode, empty collections[], and clock backwards skew. - Control Flow Branch Exhaustion: Systematically forces both truthy and falsy evaluations for every
if,else if, ternary (? :),switch/case, and short-circuit operator (&&,||,??). - Error & Exception Path Injection: Validates that invalid arguments, network timeouts, and rejected promises throw the exact expected exceptions and trigger cleanup in
finallyblocks. - State & Concurrency Verification: Verifies idempotency deduplication, exponential retry backoff, and thread-lock timeout handling.
- Mutation Resistance: Eliminates weak assertions (
expect(val).toBeDefined()) in favor of strict property matching and state invariants that fail immediately if code mutations occur.
Included Tools & Examples
scripts/coverage_auditor.py: Offline CLI that parses Python and TypeScript/JavaScript ASTs, flags untested branches with exact line numbers, and synthesizes parameterized test scaffolding.examples/payment_processor.ts&.test.ts: Complete billing engine featuring 3D Secure, fraud heuristics, and retry exhaustion with 100% verified branch coverage.examples/rate_limiter.py&test_rate_limiter.py: Token bucket implementation with thread safety, clock drift guards, and Redis failover tested to 100% branch coverage.
Requires local Python environment for AST auditing scripts. Restricted to TypeScript, JavaScript, and Python. Scope limited to unit and integration testing.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
- Software
- vitest
Node.js
Pythonjest
Permissions
Permissions are strictly limited to reading source and test files and writing test suites. No network connections are initiated.
What's inside
Frequently Asked Questions
New in Testing & Debugging
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.