Skip to main content

BorderlineData

AI Testing

BLOG

Stop asking AI to "Test my Code":

Use This 3-Step Framework for Flawless Boundary Value Analysis

 Discover how to systematically leverage AI to test a software application for boundary values and instantly surface critical edge cases without drowning your engineering team in flaky test scripts.

Let’s confess a collective industry sin: whenever we open a shiny new Large Language Model (LLM) window and ask it to look at our code, we usually type something lazy. We write something like, “Hey, write some unit tests for this function.” And the AI, being a desperately eager-to-please virtual assistant, immediately spits back five variations of the exact same “happy path” test case. It tests what happens when an integer is a comfortable 5, or when a username is a perfectly standard seven-letter string.

Congratulations. Your expensive AI tool just spent 400 tokens proving that your application functions flawlessly under absolute pristine conditions. But out in the wild, your code won’t be running in a climate-controlled greenhouse. It will be struck by real-world data constraints, chaotic inputs, and users who somehow think typing a 10,000-character string into a first-name text field is an appropriate way to spend a Tuesday afternoon.

If you genuinely want to use AI to test a software application for boundary values, you have to stop asking it to be a polite code reviewer and start instructing it to act like a destructive QA engineer. Left to its own devices, generative AI has “happy path blindness.” It wants things to work out. To shatter that optimism, you need a disciplined framework. Here is our proven three-step blueprint to force your AI tool into uncovering absolute edge case perfection.

Step 1: Break the AI’s Optimism Bias (The Prompt Matrix)

Large Language Models are trained on massive corpuses of human code, which means they naturally absorb our worst habit: believing everything will go exactly as planned. If you simply give an AI an input range of 1 to 100, it will write a test for 50. To get actual boundary value analysis (BVA) and robust equivalence partitioning, you must strictly limit the AI’s creative choices.

Instead of an open-ended request, feed your AI a deterministic prompt layout that commands it to focus exclusively on transition points. Copy and paste this structural layout directly into your LLM of choice:

Plaintext

 
Act as an aggressive, cynical Lead SDET specializing in boundary value analysis. 
Analyze the target code below. Identify every system limitation, loop counter, and input parameter. 
For each identified parameter, construct an explicit test case matrix strictly evaluating:
1. The Minimum-1 value (Just below boundary)
2. The Exact Minimum value (On the boundary line)
3. The Maximum value (On the boundary line)
4. The Maximum+1 value (Just outside boundary)

Format the final response strictly into a structured Markdown evaluation table.

By defining specific numeric, length, and spatial boundaries upfront, you prevent the model from drifting into superficial assertions. If you want to bypass the manual prompt writing altogether and get instantly generated, production-ready edge cases for your schemas, you can use our interactive Boundary Case Simulation Tool to generate them out instantly.

Step 2: Generate the Deterministic Matrix

Once you strip away the model’s desire to play nice, it becomes exceptionally competent at mathematical limits. Let’s look at a classic example: a standard e-commerce bulk-purchasing checkout system that allows a user to buy anywhere between 1 and 50 items. A standard human engineer or a poorly prompted AI will test 2 items, 10 items, and maybe 45 items.

When you utilize the step-1 structural layout, the AI yields a beautiful, bulletproof testing matrix that highlights precisely where code breaks:

Test Case IDBoundary ParameterInput ValueBoundary Logic StateExpected System Reaction
TC-001Minimum – 10Invalid (Below Range)400 Bad Request / Inline UI Error
TC-002Exact Minimum1Valid (Lower Limit)Successful Item Addition
TC-003Exact Maximum50Valid (Upper Limit)Successful Item Addition
TC-004Maximum + 151Invalid (Above Range)Block Action / Display Limit Notice
TC-005Null Statenull / NaNType Boundary FaultGraceful Catch / System Sanitization

Notice how the AI immediately zones in on 0 and 51. These are the historic flashpoints where databases throw truncation warnings, where loops encounter off-by-one errors, and where your application has a small existential crisis. For a deeper breakdown of tracking validation errors across distinct environments, check out other blog posts on the BorderlineData Engineering Blog.

Step 3: Freeze the Discovery Into a Hard Script

Here is where many modern engineering teams catastrophically trip over their own shoelaces: they take the beautiful test cases generated by the AI in Step 2 and then use that same AI to dynamically execute the tests in a live CI/CD production pipeline.

⚠️ Warning: Large Language Models are inherently probabilistic engines. They are designed to predict the most likely next word, not to execute exact assertions with 100% deterministic repetition. If you let an AI evaluate your runtime boundaries on the fly, you will eventually suffer a false positive that lets an array overflow pass straight into a production environment.

The secret formula for high-velocity software delivery is simple: Use the AI for creative discovery, but use static frameworks for rigid execution. Take the table generated in Step 2 and instruct the AI to export those explicit inputs into an absolute script using modern automation frameworks like Playwright, TypeScript, or Jest.

TypeScript

 
// An automated Playwright script generated via the Boundary Analysis Matrix
import { test, expect } from '@playwright/test';

test.describe('E-Commerce Checkout Quantity Boundary Verification', () => {
    
    test('TC-001: Inputting 0 should trigger immediate field validation', async ({ page }) => {
        await page.goto('/checkout');
        await page.fill('#quantity-input', '0');
        await page.click('#submit-btn');
        const errorMessage = await page.locator('.error-text');
        await expect(errorMessage).toHaveText('Minimum order quantity is 1 item.');
    });

    test('TC-004: Inputting 51 should gracefully prevent selection overflow', async ({ page }) => {
        await page.goto('/checkout');
        await page.fill('#quantity-input', '51');
        await page.click('#submit-btn');
        const errorMessage = await page.locator('.error-text');
        await expect(errorMessage).toHaveText('Maximum order limit exceeded.');
    });
});

The Ultimate Takeaway

AI is not here to replace the critical analytical thought of an automation expert; it is here to accelerate your ability to break things intentionally. When you systematically configure your AI models to look for boundaries, you stop writing generic code coverage scripts and start creating genuine risk-based protection maps. Stop treating your AI like a soft assistant. Instruct it to think at the absolute limits, script the outcomes into deterministic pipelines, and watch your production crash rates drop to zero.