2.1 Effective prompt development
A prompt is not just a question asked on the fly. It is a technical instruction that must be engineered. For MagicFridge, the difference between a junior and a senior engineer often lies here: the ability to get exactly what is needed from the AI.
2.1.1 The structure of an effective prompt
To obtain consistent results, a prompt should not be a vague sentence. It must follow a precise structure. The ISTQB identifies 6 key components:
- Role (persona): who should the AI imitate?
- Context: what are we talking about?
- Instruction: what must it do (action verb)?
- Input data: what information is it working on?
- Constraints: what it must NOT do.
- Output format: what should the response look like?
Red thread: MagicFridge
Here is a simple example of a structured prompt to test the "Cart" feature:
- Role: act as a senior test analyst certified by ISTQB.
- Context: we are testing the "Cart" module of the MagicFridge application.
- Instruction: generate negative test cases for the "Promo Code" field.
- Input data: this field accepts a maximum of 10 alphanumeric characters.
- Constraints: do not generate code, only textual descriptions. Do not include performance tests.
- Output format: provide the result as a Markdown table with columns ID, Scenario, Oracle.
2.1.2 Core prompting techniques
Beyond structure, there are techniques to "guide" the model's intelligence.
1. Prompt Chaining
This technique involves breaking a complex task into sequential sub-steps. The output of step 1 becomes the input for step 2, and so on.
Red thread: MagicFridge
- Prompt 1: "Analyze this user story on adding ingredients and list the business rules."
- Prompt 2: "Based on these rules, generate nominal test cases."
- Prompt 3: "Convert these test cases into Gherkin scripts."
Why? This prevents the AI from "forgetting" rules by trying to do everything at once.
2. Few-shot prompting (learning by example)
Instead of explaining everything from scratch (zero-shot), we provide the AI with a few examples (few-shots) of what is expected.
Red thread: MagicFridge
Prompt: "generate test data for vegetables."
* Example 1: Tomato -> Category: fruit-veg, Shelf-life: 7 days.
* Example 2: Carrot -> Category: root, Shelf-life: 14 days.
* Task: Do the same for "Leek".
3. Meta prompting
This is asking the AI to improve or create its own prompt. It is the AI helping the tester formulate their request better.
Red thread: MagicFridge
Tester: "I want to test the API security, but I don't know how to ask. Write an expert prompt to generate SQL injection tests for the recipe API."
2.1.3 System prompt vs user prompt
It is crucial to distinguish these two levels of interaction, especially when using APIs or advanced tools.
| Type | Description | MagicFridge Example |
|---|---|---|
| System prompt | Defines the global behavior, tone, and immutable rules of the AI. It is the "personality" of the chatbot. | "You are GUS, the MagicFridge QA assistant. You are strict, concise, and you always answer in English. You refuse to generate malicious code." |
| User prompt | The specific instruction sent at time T. This is what the tester types. | "Check if this ingredient list contains allergens." |
Syllabus point (K2 summary)
- A robust prompt contains 6 elements: role, context, instruction, input data, constraints, output format.
- Prompt Chaining: breaking down a complex task into a sequence of logical steps.
- Few-shot prompting: providing concrete examples to guide the AI's reasoning and response format.
- System prompt: the global configuration and behavioral rules (often invisible to the end-user).