Skip to content
CodeKruPro

Instruction files for test generation

25/99

Module · Working with an AI assistant as a tester

intermediate

about 35 min

What this lesson teaches

The idea

Coding assistants read instruction files from the repository, such as AGENTS.md, and apply those rules to every test they write.

Why a tester cares

Assistants have bad default habits, such as faking the backend or only checking that a page loaded. One file of rules fixes them for every developer.

Words you will meet

AGENTS.md:
a file of instructions for coding assistants, kept in the repository.
Mock:
a fake version of a system, used in place of the real one.
System under test:
the thing your tests are meant to check.

What you will do

  1. 1Fill the template
  2. 2Read what the assistant writes
  3. 3Run it
  4. 4Submit
Jump to practice

Writing a good prompt every time does not scale across a team. Coding assistants read instruction files from the repository instead: AGENTS.md is the common name, and tools have their own, such as CLAUDE.md or .github/copilot-instructions.md. Whatever the name, the file is where your team's testing rules go, so every generated test follows them.

The rules that matter most are the ones assistants break by default. Asked for a "fast, reliable" test, an assistant will often mock the backend, and then the test checks its own fake data. Asked for nothing in particular, it checks that a page loaded.

Your task

Write an AGENTS.md for the ShopLab repository. It must say where tests live, how they are named, what tests must not do, and what every checkout test must assert. Each time you Run or Submit, the scripted assistant writes a confirmation-page test from your file, and that test is what runs. You can also paste your file into the assistant console to read what it writes.

Sign in to practise

The lesson is free to read. A free account lets you talk to the practice bots, run your code and save your score. You will come back to this lesson.

ShopLab specShow
ShopLab pricing and checkout rules

Products: Coffee mug (MUG) Rs 299 · Notebook (NOTE) Rs 149 · Wireless headphones (PHONES) Rs 1,999 · Cotton T-shirt (TEE) Rs 499
Each cart line has a quantity from 1 to 10.

Coupons (one per order; applying a new coupon replaces the old one)
  SAVE10   10% off the subtotal, rounded down to the rupee. Needs a subtotal of Rs 500 or more.
           Below that the message is "SAVE10 needs a subtotal of Rs 500 or more." and the discount stays Rs 0.
  FLAT100  Rs 100 off. Needs a subtotal of Rs 999 or more.
  OLD20    Expired. Message: "This coupon has expired."
  Anything else: "Coupon not found."

Shipping: Rs 49 when the subtotal after discount is under Rs 500; free from Rs 500.
Total = subtotal - discount + shipping.

Confirmation page: heading "Order confirmed", the order ID (SL-12345), one line per item such as
"Notebook × 2", and "Total: Rs 1,234". Item lines and the total load a moment after the page.

For tests
  The app's address is in the CK_APP_URL environment variable. Pages: /shop/, /shop/cart, /shop/help.
  POST {CK_APP_URL}/api/cart with {"sku": "MUG", "qty": 2} fills the cart. page.request shares the browser's
  cookies, so a test can set up its cart through the API and then check the page.
  Test IDs (data-testid): message, subtotal, discount, shipping, total, order-id, order-line, order-total.
1

Write it up

How this is checked: When you submit, the server checks it for what the task asks: your file covers location, naming, no mocks and required assertions. When you submit, the coding assistant uses it to write code, and that code is what gets tested.

2

Scripted assistant (paste your file to preview)

No messages yet.

3

Your code

Write it in
Both are graded the same way.

Provided by the lesson. You can read it but not change it.

the suite written from your file

How this is checked: When you submit, your tests run against 5 versions of the ShopLab store: 2 correct and 3 with a planted fault. Good tests pass on every correct version and fail on every faulty one. Run tries them on the practice copy first; the result table shows each version.

Core checks earn 50 points and the harder checks the other 50. You can submit as many times as you like.

About this lesson

AGENTS.md instructions for AI test generation: rules every generated test follows

AI Testing for QA EngineersIntermediateWorking with an AI assistant as a tester

How it works

A good prompt helps once. A team needs the same rules applied to every generated test, by every developer, in every session. Coding assistants read instruction files from the repository for exactly this: AGENTS.md is the shared convention, and tools also read their own files such as CLAUDE.md or a Copilot instructions file.

The rules worth writing down are the ones assistants break by default. Asked for fast, reliable tests, an assistant often mocks the backend, and the test then checks its own fake data. Asked for nothing specific, it checks that a page loaded. An instruction file that forbids mocks of the system under test, and requires exact assertions worked out from the spec, removes both habits.

Placement matters too: say where tests live and how files are named, so generated files land where CI will run them.

About the assignment

Write an AGENTS.md for the ShopLab repository from the template, read the suite the scripted assistant writes from it, and run that suite against correct and buggy builds.

What you will do

  1. Fill each section of the template with rules a reviewer could check.
  2. State plainly that tests run against the real app, with no mocks or intercepted requests.
  3. Require exact totals and line items on the confirmation page, worked out from the spec.
  4. Read the generated suite before running it, and compare it with your rules.

Common mistakes

  • Rules that cannot be checked

    "Write good tests" changes nothing. "Every checkout test asserts the exact total" can be checked in review.

  • Allowing speed to win

    A line asking for fast tests invites mocks. Say what must not be mocked.

In a real test suite

Instruction files are reviewed like code. When a generated test slips through review with a weakness, the fix goes into the file, so the next generated test avoids it without anyone having to remember.