Generative AI · Intermediate level

Intermediate level · Module 2: Advanced Prompt Engineering · Lesson 3 of 3

Testing and Versioning Prompts

Learners build a prompt test suite in Python that runs prompts against fixed inputs and checks outputs automatically, and version prompts with Git.

In this lesson you will

  • Write automated prompt tests
  • Version prompts and record results

Key concepts

test casesautomatic checksregressionversioningpractice model for repeatability

The lesson

A prompt test suite lists inputs and checks: the output mentions the given price, stays under 60 words, contains no forbidden claims and is valid JSON. Checks run automatically after every prompt change.

Use the scripted practice model to test the code path repeatably, and a real model to measure quality. Real outputs vary, so check properties rather than exact text.

Commit prompts and test results to Git with a short message, so that any regression can be traced to a change.

Step by step

  1. Write ten test cases with property checks.
  2. Run them against two prompt versions.
  3. Record pass rates.
  4. Commit the better version with its results.

Practice activity

Create a prompt test suite for the content generator.

Expected result: A suite with pass rates that shows which version is better.

Check your understanding

  1. Why check output properties rather than exact text?

    Show answer

    Real model outputs vary between runs.

  2. What is a prompt regression?

    Show answer

    A prompt change that breaks cases that used to pass.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.