AI Tester Blueprint Foundations Prompt engineering
Chapter 2
Chapter 2 . Foundations . Prompt engineering

Prompt engineering: a test-design skill

A one-line prompt leaves the model to guess the persona, the product, the format and what to do when information is missing. RICE-POT writes those answers down, and an anti-hallucination block makes the gaps visible instead of invented. This chapter builds the prompt, then checks what a real model sent back.

7
RICE-POT parts
Role, Instructions, Context, Example, Parameters, Output, Tone.
6
RTCFR templates
Basic, PRD, API, negative-only, security and regression.
11
Rows of real model output
The committed CSV. 4 of the 11 break its 13-column header.
65
Restful-booker cases
Counted by heading. The file's own summary claims "87+".

01Why prompting is a QA skill

Ask a model to "write test cases for this PRD" and you get plausible rows. Some of them test features the PRD never mentions, cite error codes nobody defined, and come back in a different format every run. A tester would reject that from a person. Chapter 2 makes the prompt specific enough that you can reject it from a model too.

The chapter has three pillars, and this page follows them:

  1. Anti-hallucination rules (Anti_Hallucinations_Rules.md): the model may use only the inputs you give it, and must say so, in exact words, when something is missing.
  2. RICE-POT: Role, Instructions, Context, Example, Parameters, Output, Tone. A structure that forces you to state persona, constraints and format.
  3. Templates and two projects: six RTCFR templates for daily QA tasks, test cases generated from a PRD, and a Selenium framework generated from a prompt.
Question (chapter README)The answer, in short
A one-line prompt already gives OK results. Why bother?"OK" is the ceiling. Declaring persona, format and constraints is what moves an answer from mostly useful to reliably useful, every time rather than on lucky runs.
Is this over-engineering a chat message?For a one-off, yes. For repeatable QA tasks (regression suites, security checklists, daily test-case generation) a template pays for itself within three uses.
Which letter is skipped most, and what breaks?P, Parameters. Without the anti-hallucination block the model invents fields, IDs and error codes that do not exist in your PRD. The output looks plausible and ships bugs.

02RICE-POT, letter by letter

The worked prompt in Project1_TC_Gen/RICE-POT-TestCase-Prompt.md asks for functional and non-functional test cases for VWO (app.vwo.com). Each letter answers one question the model would otherwise guess.

LetterComponentWhat goes in itIn the repo's VWO prompt
RRoleThe persona the AI adoptsAn expert QA Functional Tester with 15+ years of experience
IInstructionsStep-by-step commands, mandatory rules and "Don't" listsRead the PRD and screenshots first; at least 10 cases; trace each case; stop and ask on ambiguity; three "Don't" rules
CContextBackground: the why and the whereProduct under test, and the PRD, screenshots and documents attached
EExampleOne sample row or format that sets the styleOne pipe-separated login row, "values illustrative only"
PParametersQuality, accuracy and style constraintsDeterministic, traceable, two exact fallback strings, zero invented content
OOutputThe exact artifact and formatCSV only, no preamble, 13 columns in a fixed order
TToneThe communication styleTechnical, precise, enterprise-grade; output only, no commentary
flowchart LR
  G["Goal: what should the AI produce?"] --> R["R: persona"]
  G --> I["I: steps + Don't list"]
  G --> C["C: PRD / API doc"]
  G --> E["E: one sample row"]
  G --> P["P: anti-hallucination"]
  G --> O["O: format spec"]
  G --> T["T: output-only"]
  R --> A["Assemble the template"]
  I --> A
  C --> A
  E --> A
  P --> A
  O --> A
  T --> A
  A --> X["Copy-paste prompt"]
  X --> Y{"Run on an LLM"}
  Y --> Z["Refine: tighten the Don't list, dedupe columns"]
  Z --> A
The README's RICE-POT flow: the goal drives every letter, the letters are assembled in order, and the result is refined after each run.
From the prompt's own notes for students: "R and C set up who and why; I and P set the guardrails; O and T lock the format."

03Live demo: build a RICE-POT prompt

The seven fields start with the repo's VWO prompt. Switch parts off and on, edit any field, and watch the assembled prompt, the checklist and the comparison change. The rule checks are the six strict rules of Anti_Hallucinations_Rules.md, matched as text in your prompt, with the part each one was found in.

RICE-POT prompt builderNo API key needed
data-testid=pe-toggle-pdata-testid=pe-field-rdata-testid=pe-loaddata-testid=pe-paramsdata-testid=pe-clear
Assembled prompt

      Anti-hallucination rules it carries
      
    Parts present
    Side by side with a one-line prompt
    CheckOne-line promptYour RICE-POT prompt
    PromptWrite test cases for this PRD.The assembled prompt above
    Words
    RICE-POT parts
    Anti-hallucination rules
    Output format pinned
    Left for the model to guess
        Field text is the repo file, verbatim, except one character: in T the file uses a long dash before "no commentary", written here as a comma. The checks are text matches, so they tell you a rule is stated; whether a model obeys it is what you test next.

        04The anti-hallucination block

        Anti_Hallucinations_Rules.md is a ROLE block you put above any QA prompt that generates facts. It limits the model to the inputs you provide, and it gives a gap an exact name.

        Anti_Hallucinations_Rules.md (lines 10-52)
        ROLE: You are a QA assistant operating under strict verification rules.
        
        ## SCOPE OF KNOWLEDGE
        
        You may ONLY use information explicitly provided in:
        - PRD
        - API documentation
        - Logs
        - Screenshots
        - Test data
        - User input
        
        ## STRICT RULES (MANDATORY)
        
        1. DO NOT invent features, APIs, error codes, UI elements, or behavior.
        2. DO NOT assume default or "typical" system behavior.
        3. If information is missing or unclear, respond with:
           "Insufficient information to determine."
        4. Every assertion must be traceable to provided input.
        5. If a detail is inferred, label it explicitly as:
           "Inference (low confidence)".
        6. Output must be deterministic and repeatable.
        
        ## PROCESS YOU MUST FOLLOW
        
        **Step 1:** Extract verifiable facts from the input.
        
        **Step 2:** List unknown or missing information.
        
        **Step 3:** Generate output ONLY from Step 1 facts.
        
        **Step 4:** Perform a self-check for hallucinations or contradictions.
        
        ## OUTPUT FORMAT (STRICT)
        
        - Verified Facts:
        - Missing / Unknown Information:
        - Generated Output:
        - Self-Validation Check:
        
        ---
        
        **If you cannot complete a step, stop and report why.**

        The two fallback strings are the part a tester should care most about. Insufficient information to determine. and Inference (low confidence) are greppable: a reviewer, or a script in a pipeline, can count them in the output instead of trusting fluent text. The same rules, shaped as a RICE-POT Parameters block:

        blank-template-rice-pot.md (lines 36-44)
        ## Recommended Parameters block (for factual or technical output)
        ```
        - Output must be deterministic (same input → same output).
        - Every assertion must be traceable to a provided input.
        - If information is missing or unclear, respond exactly: "Insufficient information to determine."
        - If a detail is inferred, label it exactly: "Inference (low confidence)".
        - Do not invent features, IDs, APIs, error codes, UI elements, or behavior.
        - Do not assume default or "typical" system behavior.
        ```
        Stated is not obeyed. The rules reduce invention; they do not prevent it. Project 1 below shows a real output that still needs checking.

        05Project 1: test cases from a PRD, then check them

        The repo commits one real model output for the VWO prompt: output/deepseek_csv_20260524_0d9b7c.csv, a header and 11 login cases (TC-LOGIN-001 to 007, TC-SEC-001, TC-NAV-001, TC-ACC-001, TC-LOAD-001). Parse it before you trust it. Four rows break the 13-column contract because a field contains a comma and the field is not quoted:

        RowFields parsedWhere the extra commas are
        TC-LOGIN-00214Test Data: Invalid email format (e.g., "userexample.com")
        TC-SEC-00115Test Steps: (e.g., 10+ times in 1 minute); Expected Result: After threshold exceeded, system returns ...
        TC-ACC-00119Test Data: (Tab, Enter, Space); Test Steps list five elements separated by commas
        TC-LOAD-00115Pre-Condition: (e.g., 10 Mbps, 50ms latency)
        deepseek_csv_20260524_0d9b7c.csv (lines 1-3)
        Scenario, TID, Test Data, Test Case Description, Pre-Condition, Test Steps, Expected Result, Actual Result, Status, Executed By (QA Name), Misc (Comments), Priority, Is Automated
        Login, TC-LOGIN-001, Valid email + valid password, Verify successful login with valid credentials (positive scenario), User account exists and is active, 1. Navigate to app.vwo.com 2. Enter valid registered email 3. Enter valid corresponding password 4. Click Login button, User is redirected to main VWO dashboard; session is established; user sees personalized dashboard, , , , , High, No
        Login, TC-LOGIN-002, Invalid email format (e.g., "userexample.com"), Verify real-time email format validation triggers on blur (negative scenario), Login page loaded; JavaScript enabled, 1. Navigate to app.vwo.com 2. Click into email field 3. Type "userexample.com" 4. Tab or click out of email field (blur), Field shows email format validation error message; error is immediate and clear; specialized mobile keyboard not triggered (desktop context), , , , , High, No

        The second artifact, Restful_Booker_API_Test_Cases.md, was generated from Restful-booker.pdf (the prompt and model are not recorded). It holds 65 cases in 9 groups (2, 7, 9, 8, 15, 8, 6, 8, 2), while its own summary says "87+". The PDF documents only 200 OK and 201 Created; the cases also assert 204, 400, 401, 403, 404, 405 and 415, often hedged as "403 Forbidden or 401 Unauthorized". Under the rules above, each of those should carry Inference (low confidence).

        flowchart LR
          IN["PRD and screenshots, or an API PDF"] --> PR["RICE-POT prompt + Parameters block"]
          PR --> LLM["Any LLM"]
          LLM --> CSV["CSV only"]
          CSV --> REV{"QA review"}
          REV -->|"13 columns, 10+ rows, traceable"| TM["Import to the test tool"]
          REV -->|"broken rows, invented codes"| FIX["Tighten the prompt, or ask"]
          FIX --> PR
        Generation is half the job. The review step is where a tester earns the output.
        The Restful-booker cases use the API's public demo admin credentials. Take them from the API documentation when you need them; they are not reproduced on this page.

        06Project 2: a Selenium framework from one prompt

        Project 2 tests whether RICE-POT can produce code, not just test cases. The whole brief, from Problem.md:

        Problem.md
        We have to generate a Selenium automation framework from scratch where you need to add a two-page object model, proper production ready.

        The output, AdvanceSeleniumFramework/, is a Maven project on Java 11 with Selenium 4.25.0 and TestNG 7.10.2 that tests the Salesforce login page in headless Chrome.

        FileWhat it does
        pom.xmlDependencies, Java 11, and Surefire wired to testng.xml
        config.propertiesApp URL, credential placeholders, explicit (20 s) and implicit (10 s) timeouts
        ConfigReader.javaLoads the properties once; throws on a missing key or a non-integer value
        BaseTest.java@BeforeMethod starts headless Chrome and opens the URL; @AfterMethod quits
        LoginPage.javaPageFactory page object: six XPath locators, explicit waits, fluent methods, no Thread.sleep
        ValidLoginTest.javaFails fast in @BeforeTest while the credentials are still placeholders; checks the page and a real login
        InvalidLoginTest.javaA @DataProvider with 5 invalid logins, plus a "no error on a fresh load" check
        testng.xml, testng-smoke.xmlThe full suite, and a smoke suite with one method
        LoginPage.java (lines 38-54)
            public LoginPage(WebDriver driver) {
                this.driver = driver;
                this.wait = new WebDriverWait(driver,
                        Duration.ofSeconds(ConfigReader.getInt("timeout.explicit")));
                PageFactory.initElements(driver, this);
            }
        
            public LoginPage enterUsername(String username) {
                try {
                    wait.until(ExpectedConditions.visibilityOf(usernameField));
                    usernameField.clear();
                    usernameField.sendKeys(username);
                } catch (TimeoutException e) {
                    throw new RuntimeException("Username field not visible within timeout", e);
                }
                return this;
            }
        flowchart TD
          CFG["config.properties"] --> CR["ConfigReader"]
          CR --> BT["BaseTest"]
          BT -->|"@BeforeMethod"| D["ChromeDriver, headless"]
          BT -->|"@AfterMethod"| Q["driver.quit()"]
          VT["ValidLoginTest"] --> LP["LoginPage: PageFactory, XPath only"]
          IT["InvalidLoginTest + @DataProvider"] --> LP
          VT -.->|extends| BT
          IT -.->|extends| BT
          SUITE["testng.xml"] --> VT
          SUITE --> IT
          SMOKE["testng-smoke.xml"] --> IT
        What the prompt generated, as the README draws it and the code confirms.
        terminal
        # JDK 11+ and Maven 3.9+
        cd chapter_02_Prompt_Eng/Project2_Selenium_Framework/AdvanceSeleniumFramework
        mvn -q clean test-compile
        mvn test                       # runs testng.xml, the suite pom.xml names
        Before you run it:
        • Put a real Salesforce test account in config.properties (app.username, app.password). With the REPLACE_WITH_... placeholders, ValidLoginTest throws in @BeforeTest on purpose, so a forgotten config never passes.
        • The README also shows mvn test -DsuiteXmlFile=testng-smoke.xml. That is not verified: pom.xml hard-codes testng.xml, so the property is most likely ignored and the full suite runs.
        • The brief asks for "a two-page object model"; the framework has one page object, LoginPage. The prompt, or its review, missed a requirement.

        07Six RTCFR templates

        The templates/ folder holds six copy-paste prompts for the QA tasks that come up every week. They follow RTCFR (Role, Task, Constraints, Format, Requirements), the lightweight cousin of RICE-POT. All six are in the Solution tab, verbatim.

        FileUse it forOutput columnsConstraint worth keeping
        01_TestCaseGeneration_Prompt.mdBasic test cases from free-form requirementsTest ID, Description, Pre-conditions, Steps, Expected Result, PriorityMissing information is written as "Not specified"
        02_TestCases_from_prdFull PRD coverage: functional, negative, boundary, edgeTID, Category, Description, Pre-conditions, Steps, Expected, Priority"Do NOT invent error messages or codes"; unclear items marked "Needs clarification"
        03_API_Test_Generation.mdAPI endpoint tests from the API docsTest ID, Endpoint, Method, Request Body, Expected Status, Expected Response"Include exact status codes from docs"
        04_Negative_TC_Only.mdA negative-only suiteTest ID, Invalid Scenario, Input, Expected Error"Do NOT include happy path scenarios"
        05_Secuirty_Test.mdSecurity cases, OWASP Top 10 where it appliesTest ID, Security Risk, Attack Vector, Expected Secure Behavior"Do NOT include actual malicious payloads"
        06_Regression_Suite.mdA regression suite for one moduleTest ID, Scenario, Data Setup, Steps, Est. Time, Priority"Estimate execution time per test"
        1. Open the file and copy the prompt block.
        2. Replace [FEATURE], [PASTE REQUIREMENTS], [PASTE PRD HERE] and the like with your input.
        3. Paste it into any AI tool. Keep the CONSTRAINTS block intact: that is what stops invention.
        RTCFR has no Example and no Parameters block. When the output will be reviewed, imported or counted, move up to RICE-POT and add the anti-hallucination Parameters.

        08What to watch

        • The worked prompt targets VWO. The README suggests attaching Restful-booker.pdf; if you do, rewrite C (and the product in I) first, or the model is told to test one product from another product's document.
        • CSV is a contract, so parse it. Unquoted commas shift columns. Adding "wrap every field in double quotes" to O is a cheap fix to try.
        • A model's count of its own output is not a count. 65 cases, "87+" claimed. Count rows yourself.
        • Traceability needs a column. Instruction 5 asks to trace every case, but the 13 columns have nowhere to put the reference, so nothing in the file can be checked against the PRD.
        • Check every status code and message against the source. Anything the document does not state is an inference, and the rules say to label it.
        • Match the tone to the output. SKILL.md's guardrail: "code-only" suits code, not a CSV; ask for "output-only, no commentary".
        • Two files the skill points to are missing. SKILL.md refers to references/worked-example.md and references/blank-template.md; the blank template is blank-template-rice-pot.md next to it, and there is no worked example.
        • The README's sample CSV row is illustrative. The TC_API_007 row it shows is not in the committed output.