Automating Test Plans with LLMs and Ollama: a practical architecture
Writing Test Plans and test cases is essential for software quality, but it is also one of the slowest and most repetitive QA tasks. In my current job at UST, on a project for Telefónica, I have built a solution that uses language models run locally with Ollama to speed up that work without losing control. Here I explain the architecture in general terms, without going into client data.
The problem
A Test Plan starts from requirements or specifications. From there you have to derive:
- Test cases with preconditions, steps and expected results.
- Unit or integration tests for each behaviour.
- Documentation explaining what is covered and what is not.
Doing it by hand is slow, and edge cases are easy to miss. Using a cloud LLM solves the speed problem, but it may not be acceptable if the requirements contain sensitive information. That is why the local option is key.
A five-step architecture
- Structured input: requirements and specifications in a fixed format.
- Templated prompt: the model receives clear instructions and an output schema.
- Local generation: a quantised model in Ollama produces the proposal.
- Automatic validation: schema, required fields and duplicates are checked before anything is accepted.
- Human review and traceability: a person approves the result and everything is versioned.
Step 4 is the most important one. An LLM can get the format wrong or invent a field, so its output is never trusted without validation.
Example: generating test cases from a requirement
Ollama exposes a local HTTP API. With format: "json" we ask for a JSON response, which we then validate:
import json
import requests
OLLAMA_URL = "http://localhost:11434/api/generate"
def generate_cases(requirement: str) -> list[dict]:
prompt = f"""You are a QA engineer. Generate test cases as JSON,
a list of objects with the fields: id, title, preconditions, steps and expected_result.
Requirement: {requirement}"""
r = requests.post(
OLLAMA_URL,
json={"model": "llama3.2", "prompt": prompt, "format": "json", "stream": False},
timeout=120,
)
r.raise_for_status()
cases = json.loads(r.json()["response"])
# Minimal validation before accepting the output
fields = {"id", "title", "preconditions", "steps", "expected_result"}
for case in cases:
missing = fields - case.keys()
if missing:
raise ValueError(f"Case {case.get('id', '?')} is incomplete: missing {missing}")
return cases
This snippet is deliberately simple. In a real system I would add retries, duplicate detection and a schema validated with a library such as Pydantic.
What you gain with this approach
- Speed: the first draft of a Test Plan appears in minutes.
- Coverage: the model suggests edge cases that are sometimes forgotten.
- Privacy: requirements never leave your infrastructure.
- Predictable cost: you don’t pay per token on every run.
What not to forget
- Local models are usually less capable than the large cloud models. Quality has to be measured against reference cases.
- AI proposes; people decide. The goal is to reduce manual work, not to remove review.
- Version your prompts like code. A small change in the template can change the results a lot.
To finish
Automating Test Plans with LLMs is a real improvement when it is designed with validation, human review and data under control. If your QA team wants to explore something like this, you can ask me to call you and we’ll look at your specific case.