← Latest papers
💻 computer science

When Generative AI Writes Test Cases: Scenario-Driven Evaluation of Generated Tests

This paper introduces a scenario-driven evaluation methodology to compare GenAI-generated test suites against human-written ones, revealing that while direct prompts recover more expected behaviors, ideate-then-implement strategies yield more efficient suites with fewer duplicates, and ideate-only approaches effectively uncover additional test scenarios.

Original authors: Baris Ardic, Idil Isil Yildirim, Carolin Brandt, Andy Zaidman

Published 2026-07-06
📖 4 min read☕ Coffee break read

Original authors: Baris Ardic, Idil Isil Yildirim, Carolin Brandt, Andy Zaidman

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a chef trying to teach a very talented, but sometimes over-eager, AI assistant how to cook a specific dish. You have a "Gold Standard" recipe card (the manual test suite) that lists exactly what the dish should taste like and how to check if it's done right.

This paper is about asking the AI to write its own set of "taste tests" to see if the dish is good, and figuring out the best way to ask it to do so.

Here is the breakdown of the study using simple analogies:

The Problem: The "Black Box" of AI Testing

Software developers use AI to write tests (checks that ensure code works). But usually, we only check if the AI's tests "pass" or "fail" or how many lines of code they cover. It's like checking if a student got the right answer on a math test without looking at how they thought about the problem.

The researchers wanted to know: Does the AI actually understand the different "flavors" (scenarios) of the problem, or is it just guessing?

The Three Ways to Ask the AI (The Prompting Strategies)

The researchers tried three different ways of talking to the AI (using GPT-4o) to generate these tests. Think of these as three different ways to ask a sous-chef for a tasting menu:

  1. Direct-Implement (The "Just Do It" Approach):

    • The Prompt: "Here is the code. Write me a full list of tests right now."
    • The Result: The AI rushes to the finish line. It finds most of the correct "flavors" (scenarios) you wanted, but it gets a bit messy. It writes the same test multiple times (duplicates) and sometimes invents weird, unnecessary tests. It's like a chef who makes 20 samples of soup, but 10 of them are identical.
  2. Ideate-Only (The "Brainstorming" Approach):

    • The Prompt: "Don't write the code yet. Just tell me what kinds of tests I should write. Give me a list of ideas."
    • The Result: The AI acts like a creative brainstorming partner. It comes up with the most new and interesting ideas that weren't in your original recipe. However, it doesn't actually cook the food (write the code), so you have to do the work to turn those ideas into real tests.
  3. Ideate-Then-Implement (The "Plan First" Approach):

    • The Prompt: "First, think of the test ideas. Then, use those specific ideas to write the actual code."
    • The Result: This is the most organized approach. The AI pauses to think before acting. It produces a smaller, cleaner list of tests with very few duplicates. It's like a chef who writes a shopping list, checks it, and then cooks only what is needed.

The Key Findings (The Taste Test Results)

  • Recovering the "Gold Standard":
    When the AI was asked to just "do it" (Direct-Implement), it found the most of the original test scenarios you already had. But, it was messy. When it was forced to "plan first" (Ideate-Then-Implement), it was cleaner but missed a few of the original scenarios.

    • Analogy: If you asked the AI to find all the red marbles in a jar, the "Just Do It" method found almost all of them but also grabbed a bunch of blue ones by mistake. The "Plan First" method grabbed fewer red ones but didn't grab any blue ones.
  • The "New" Ideas:
    The "Brainstorming" (Ideate-Only) method was the best at finding new scenarios that weren't in your original recipe. Sometimes, these new ideas were actually very valuable—they caught bugs that the original tests missed. But often, they were just minor variations of things you already knew.

  • The "Broken" Tests:
    Some of the AI's tests failed to run. The researchers looked closely at why they failed.

    • Most failures were simple: The AI guessed the wrong number (e.g., "I think the answer is 5," but it's actually 4). These are easy to fix.
    • Some failures were deep: The AI fundamentally misunderstood how the code worked (e.g., thinking a door opens when it actually locks). These are harder to fix because the AI's logic was wrong.

The Big Takeaway

There is no single "perfect" way to ask the AI to write tests. It depends on what you need:

  • If you want to catch everything the original team thought of, even if it's messy, use Direct-Implement.
  • If you want a clean, efficient list without duplicates, use Ideate-Then-Implement.
  • If you want to discover new, creative ideas that you haven't thought of yet, use Ideate-Only (and then pick the best ones to build).

The study concludes that by looking at the ideas (scenarios) behind the tests rather than just the code itself, developers can make smarter choices about how to use AI in their work.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →