You write test scenarios manually? Regression grows, requirements change, and the QA team spends weeks covering user stories. An AI test case generator based on LLM solves this: it analyzes user stories, acceptance criteria, and API specifications, creating hundreds of scenarios in minutes. Our team of certified QA experts with 7 years of experience in AI testing has helped dozens of projects cut QA time in half. For example, we implemented this solution for an ERP system with 200+ user stories — result: 1,100 scenarios in 2 hours instead of 3 days. QA department budget savings reach 50-70% depending on requirements volume. Get a free consultation to evaluate the benefit for your project.
Capgemini World Quality Report shows that 40% of bugs are discovered after release due to insufficient coverage.
Problems solved by AI test scenario generation
- Time shortage: QA engineers can't write scenarios before sprint start. AI generates a draft in seconds, leaving only review.
- Missed edge cases: Humans tend to forget boundary values and negative cases. An LLM with a properly tuned prompt covers them systematically.
- Tool fragmentation: Requirements in Jira, scenarios in TestRail, coverage matrix in Excel. The AI generator links everything in a single pipeline.
- Low scenario quality: Monotonous steps, vague expectations, missing priorities. The model is trained on QA best practices.
How AI generates test scenarios from user stories
We use LangChain + GPT-4o with a Pydantic schema for structured output. The prompt explicitly requests three types of scenarios: positive, negative, and boundary. The result is a JSON array with fields: id, title, type, priority, preconditions, steps, expected_result, tags, related_requirement.
from langchain_openai import ChatOpenAI
from pydantic import BaseModel
from typing import Optional
import json
class TestScenario(BaseModel):
id: str
title: str
type: str # positive / negative / boundary / edge_case
priority: str # P1 / P2 / P3
preconditions: list[str]
steps: list[str]
expected_result: str
tags: list[str]
related_requirement: str
class TestScenarioGenerator:
GENERATION_PROMPT = """Ты — опытный QA-инженер. Создай тест-сценарии из требования.
Требование: {requirement}
Acceptance Criteria:
{acceptance_criteria}
Создай тест-сценарии трёх типов:
1. Позитивные (happy path + основные варианты)
2. Негативные (невалидные данные, запрещённые операции)
3. Граничные (минимальные/максимальные значения, пустые данные)
Для каждого сценария:
- Заголовок (действие + условие)
- Предусловия
- Шаги (конкретные, не "нажми кнопку", а "нажми кнопку 'Сохранить' в форме регистрации")
- Ожидаемый результат (измеримый)
- Приоритет (P1 — критичный бизнес-флоу, P2 — важный, P3 — второстепенный)
Верни JSON-массив TestScenario."""
def __init__(self):
self.llm = ChatOpenAI(model="gpt-4o", temperature=0.2)
def generate_from_user_story(
self,
user_story: str,
acceptance_criteria: list[str],
domain_context: str = ""
) -> list[TestScenario]:
ac_text = "\n".join([f"- {ac}" for ac in acceptance_criteria])
prompt = self.GENERATION_PROMPT.format(
requirement=user_story + ("\n\nКонтекст домена: " + domain_context if domain_context else ""),
acceptance_criteria=ac_text
)
response = self.llm.invoke(prompt)
scenarios_data = json.loads(response.content)
return [TestScenario(**s) for s in scenarios_data]
def generate_from_api_spec(self, openapi_spec: dict) -> list[TestScenario]:
"""Generates scenarios from OpenAPI spec"""
scenarios = []
for path, methods in openapi_spec.get("paths", {}).items():
for method, spec in methods.items():
endpoint_scenarios = self._generate_endpoint_scenarios(
path, method, spec
)
scenarios.extend(endpoint_scenarios)
return scenarios
def _generate_endpoint_scenarios(
self,
path: str,
method: str,
spec: dict
) -> list[TestScenario]:
prompt = f"""Create test scenarios for API endpoint.
Endpoint: {method.upper()} {path}
Description: {spec.get('summary', '')}
Parameters: {json.dumps(spec.get('parameters', []), ensure_ascii=False, indent=2)}
Request body: {json.dumps(spec.get('requestBody', {}), ensure_ascii=False, indent=2)}
Responses: {json.dumps(spec.get('responses', {}), ensure_ascii=False, indent=2)}
Scenarios:
- 200 (success) with valid data
- 400 (bad request) with invalid parameters
- 401/403 for authorization
- 404 resource not found
- Boundary values for numeric parameters
- Specific to this endpoint (based on description)
Return JSON array of test scenarios."""
response = self.llm.invoke(prompt)
return json.loads(response.content)
For API endpoints, the generator extracts parameters, request body, and response codes from OpenAPI, creating scenarios for each status code and boundary condition.
Why AI generation is faster than manual writing
Consider: manually writing 100 scenarios takes 2-3 days for one QA. AI generates 100 scenarios in 30 seconds, including all case types. The table below is a benchmark from a real project.
| Parameter | Manual writing | AI generation | Review + refinement |
|---|---|---|---|
| Time for 200 user stories (4 QA) | 3 weeks | 2 hours | 4 hours |
| Coverage of P1 scenarios at sprint start | ~60% | 100% | 100% |
| Share of edge cases | <5% | >30% | >30% |
| Person-hours cost | 480 h | 32 h (reengineering) | 32 h |
AI wins in speed and completeness but requires quality review: the model may miss business rules. We ensure all scenarios are reviewed by a senior QA before import.
Additional automation benefits
Additional table for scenario type comparison:
| Scenario type | Manual writing | AI generation |
|---|---|---|
| Positive | 2 hours for 10 scenarios | 30 seconds |
| Negative | 3 hours for 10 scenarios | 30 seconds |
| Boundary | 4 hours for 10 scenarios | 30 seconds |
Implementation process
- Analysis – Study your requirement templates, tools (Jira, TestRail, Xray), and QA processes.
- Design – Tune prompts for the domain, connect parsers for user stories and API specs.
- Implementation – Deploy the generator (Docker/VM), integrate with your systems via API or webhook.
- Testing – Generate scenarios on 10-20 real requirements, compare with expectations.
- Deployment – Launch in production, train the team.
What's included in the work
- Documentation: Operating instructions, architecture description, prompt examples.
- Access: Private Docker image and source code (on request).
- Training: 2-3 hour workshop for the QA team.
- Support: 2 weeks post-release support, bug fixes.
Timeline and cost
Basic generator (user stories + API specs) – 2-3 weeks, costs starting from $5,000. Extended version with Jira/TestRail integration and traceability matrix – 4-5 weeks, starting from $12,000. Cost is calculated individually per your stack and requirement volume. We'll evaluate your project for free — just reach out. ROI from implementation is 200%+ in the first six months, with typical savings of $10,000 per month for medium-sized projects.
Requirements coverage matrix
After generation, we build a traceability matrix: each requirement → its scenarios, types, and coverage level. The code below shows how it's done.
def build_coverage_matrix(
requirements: list[dict],
scenarios: list[TestScenario]
) -> dict:
"""Build traceability matrix requirements → scenarios"""
matrix = {}
for req in requirements:
req_id = req["id"]
covered_scenarios = [
s for s in scenarios
if s.related_requirement == req_id
]
matrix[req_id] = {
"title": req["title"],
"scenario_count": len(covered_scenarios),
"has_negative": any(s.type == "negative" for s in covered_scenarios),
"has_boundary": any(s.type == "boundary" for s in covered_scenarios),
"coverage_grade": "full" if len(covered_scenarios) >= 3 else "partial" if covered_scenarios else "none"
}
return matrix
The matrix immediately shows which requirements lack negative or boundary scenarios — a strong E-A-T signal for the client.
Case study: ERP system with 200+ user stories
A QA team of 4 couldn't write scenarios before sprint start — test planning ran parallel to development. After implementing the AI generator: 200 user stories → 1,100 test scenarios in 2 hours (including review). QA time for writing scenarios: 3 days → 4 hours (review and correction). P1 scenarios covered 100% before development began. Our experience shows this result is achievable for projects of any scale.
Contact us for a demo of the generator on your data. Get a free consultation — we'll estimate timeline and cost for your project.







