Quality Booster
Cheat Sheet Anfänger

Prompt Engineering for Testers

Practical techniques for effective AI prompts in software testing: 6 building blocks, proven patterns, and copy-paste templates for everyday use.

Kompakte PDF-Version Optimiert für A4-Druck
Prompt Engineering AI Testing GenAI

What Makes a Good Prompt?

A good prompt is like a good test instruction: clear, complete, and actionable. After several months of working with various AI tools, I’ve learned: the quality of the answer directly depends on the quality of the question.

Here’s my proven framework that works in most cases:

The 6 Building Blocks of a Prompt

Not every prompt needs all six, but the more complex the task, the more of these you should include:

Building BlockQuestionExample
RoleWho should answer?”You are an experienced QA engineer…”
TaskWhat should be done?”Generate test cases for…”
ContextWhat do you need to know?”This is an e-commerce app…”
InputWhat data is available?”User Story: As a customer I want to…”
ConstraintsWhat should be avoided?”Max 10 test cases, consider GDPR…”
FormatHow should it look?”Table with ID, Description, Expected Result”

My experience: At first, I often prompted too briefly and was disappointed with the results. Now I take an extra 30 seconds for the prompt and save myself several iterations afterward.


Prompt Techniques I Use Regularly

Zero-Shot: The Quick Query

For simple, clear tasks, one sentence is often enough:

Generate a test plan for a login feature.

When to use: When the goal is obvious and you want to see what the AI delivers first.

One-Shot: Setting the Format

When the result should come in a specific structure:

Generate test cases in the following format:

Example:
- ID: TC001
- Description: Valid login with email
- Steps: 1. Enter email 2. Enter password 3. Click button
- Expected: Redirect to dashboard

Task: Create 5 test cases for password reset.

My tip: One good example is worth gold – it shows the AI exactly what you expect.

Few-Shot: Letting Patterns Emerge

For more complex tasks, multiple examples help:

Here are examples of boundary value analysis:

Input: Age 18-65
Boundary values: 17, 18, 65, 66

Input: Password 8-20 characters
Boundary values: 7, 8, 20, 21

Input: Cart 1-10 items
Boundary values:

Why this works: The AI recognizes the pattern and applies it to the new case.

Persona: Buying Expertise

Sometimes you want a specific perspective:

You are a security tester with 10 years of experience 
in OWASP. Find potential security vulnerabilities 
in the following code:

[Insert code]

What I like about it: You get answers from a viewpoint you might not have yourself.

Step-by-Step: Making the Thought Process Visible

For complex analyses:

Analyze the following bug report step by step:

1. What is the reported behavior?
2. What is the expected behavior?
3. What could be potential root causes?
4. What should be investigated next?

Bug report: [insert]

The advantage: You see how the AI arrives at its conclusion – and can spot false conclusions.


My Copy-Paste Templates

Template: Generate Test Cases

You are a QA engineer focused on E2E testing.

Task: Generate test cases for the following feature.

Context:
- Application: [Web/Mobile/API]
- Tech stack: [React/Angular/etc.]
- Test framework: [Playwright/Cypress/etc.]

User Story:
"""
[Insert user story]
"""

Acceptance Criteria:
1. [Criterion 1]
2. [Criterion 2]
3. [Criterion 3]

Constraints:
- Use [Given-When-Then] format
- Consider Happy Path + Edge Cases
- Maximum 8 test cases

Format:
| ID | Description | Precondition | Steps | Expected Result | Priority |

Template: Bug Analysis

You are an experienced Test Manager.

Analyze the following bug report:

Title: [Bug title]
Description: [What happened?]
Steps: [1..., 2..., 3...]
Expected: [What should happen?]
Actual: [What actually happened?]

Think step by step:
1. Categorize the bug (Functional/UI/Performance/Security)
2. Estimate severity (Critical/High/Medium/Low)
3. Identify potential root causes
4. Recommend next investigation steps
5. Suggest which tests should be added

Template: Generate Test Data

Generate realistic test data for:

Scenario: [Registration/Checkout/etc.]
Number of records: [e.g., 10]

Constraints:
- Vary in length and format
- Include both valid AND invalid data intentionally
- Consider international formats (US, EU)
- Add edge cases (empty strings, special chars, Unicode)

Output as JSON:
{
  "testData": [
    {
      "id": "...",
      "input": {...},
      "expectedValid": true/false,
      "edgeCaseType": "..."
    }
  ]
}

System vs. User Prompt

System Prompt (sets the behavior):

You are a conservative code reviewer. 
- Flag every security risk
- Ask for clarification when uncertain
- Answer concisely

User Prompt (specific task):

Review the following API endpoint:
[Code]

Remember: System Prompt = Personality, User Prompt = Task.


Getting a Second Opinion

Use a second LLM for evaluation:

Evaluate the following test cases against these criteria:

Test Cases:
"""
[Generated Test Cases]
"""

Evaluation Criteria (Score 1-5):
1. Completeness (all ACs covered?)
2. Clarity (unambiguous steps?)
3. Testability (can be automated?)
4. Edge case coverage
5. Result unambiguity

Provide for each criterion:
- Score
- Brief justification
- Improvement suggestions

My experience: It sounds like overhead, but for important test cases, it’s worth it. The AI often finds gaps I’ve overlooked.


Solving Prompt Problems

ProblemSolution
Too unstructuredImprove Format (table, JSON, etc.)
Too genericExpand Context (more domain details)
Wrong focusMake Task more precise (“Focus on security not UI”)
Too longAdd Constraints (“Max 5 points, max 20 words each”)
InconsistentUse One-Shot/Few-Shot with examples

Common Mistakes – And How I Avoid Them

What I used to doWhat I do now
”Test this""Generate 5 test cases for the login function in Given-When-Then format”
No contextInclude User Story + Acceptance Criteria
No formatExplicitly define desired format
Everything at onceBreak task into sub-steps
Prompt once → doneIterate: Prompt → Output → Feedback → Improve

Breaking Down Tasks

For complex requests:

Step 1: Analyze the User Story and extract:
- Main actions
- Data fields
- Business rules

Step 2: For each main action:
- Identify Happy Path
- Identify Edge Cases
- Identify Error Scenarios

Step 3: Formulate test cases:
- Given: [State]
- When: [Action]
- Then: [Expectation]

Why this helps: The AI stays focused and you get better intermediate results.


My Quick Wins

  1. Negative Prompting: What should be avoided?

    Generate test cases. Avoid:
    - Too similar test cases
    - Non-testable steps
    - Vague formulations
  2. Generate multiple times: Get three variants and compare

    Generate 3 different approaches for test cases.
    Compare them and recommend the best one.
  3. Optimize the prompt: Ask the LLM itself

    Improve the following prompt for clarity:
    [Your current prompt]

Note: These techniques are based on my personal experiences with various AI tools in everyday testing work. Not everything works in every context – trying out and adapting is the key.

Mehr praktische Ressourcen im Blog

Zur Kompakt-Version →