endueendue

Test Generation

Use when someone wants automated tests written for existing code. Saves one test file, with expected values taken from the rules, and shows which rules the code seems to break.

v2.0.0

このスキルでできること

エージェントが従う指示の全文です。ログインしなくても、すべて読めます。

Test generation

Turn the user's rules into one automated test file, and show where the code seems to break them.

When to use

Use it to write test code. Use test-planning for manual tests and bug reports, debugging to find why something fails, and refactoring to make working code clearer. Answer a general question about testing in chat.

How to work

  1. List the code, rules, worked examples, test framework, file path, imports and style. Keep the user's rule labels, or use R1, R2… Use their versions and names exactly. If the framework, path or import is missing, choose one that fits the language, use it throughout and call it an assumption. If there are no rules at all, ask for them and don't save a file.
  2. Choose the cases for each rule: a normal one, both sides of every limit and the limit itself, every error, and any input where two rules apply. Keep the user's case IDs, such as those from a test plan, and continue from the last one. Otherwise start at TC-01. Each case checks one behavior and catches one bug you can name.
  3. Work out each expected value by hand, using only the rules. Write it as a fixed value, never with the code's own formula or from what the code returns now. Check it against the user's examples. If an example disagrees with a rule, or the rules don't cover something, leave that case out, list it under Not covered and ask.
  4. Read the code with each input and predict the result. Should pass: the code gives the expected result. Should fail: it gives a different one. Can't tell: it depends on code or settings you can't see.
  5. Test only what callers can use. Use made-up data and fixed dates, times and random values. Each test must work alone and in any order. Replace only systems outside the code, such as a payment service or the clock, and say why in a comment. Don't use fixed waits.

The result

If the task sets another format, use it with the same parts in the same order. Otherwise, save one file with save_output. Use the file name the user gives. If there isn't one, use the target's name and the normal test file ending for its language. The file must hold code only, with no Markdown fences. If you can't save it, put the whole file in one code block at the end of the reply. Write comments, test names and the reply in the user's language, unless they ask for another.

The file always has these seven parts, in this order, each under a numbered comment. If one is empty, keep its comment and say why.

  1. About: what's tested, where the rules come from, the framework, the run command, assumptions and "Not run".
  2. Case map: one comment line for each case, in ID order: ID | rule | input | expected | bug it catches | prediction.
  3. Setup: imports, then any shared data or replacements.
  4. Normal cases: in rule order.
  5. Limits: the values at each limit and on both sides, and inputs where two rules apply.
  6. Errors: invalid input and failures.
  7. Not covered: each missing rule or behavior, and why.

Each case goes in one part only. Number cases in the order their tests appear, unless the user gave IDs. Start each test name with its ID and rule, such as "TC-01 R1". In a table of cases, each row needs its own ID and name.

The reply always has these five parts, in this order:

  1. Verdict: one sentence with the number of tests, how many Should fail and the main reason.
  2. Case table: Rule | Case | Expected result | Bug it catches | Prediction. Put Should fail first, then Can't tell, then Should pass, each in ID order. Give the input before each expected result. Below the table, write "From reading the code; not run."
  3. Where the code and rules differ: a list with the code line, what the code gives, what the rule needs, and the cases affected. Say "None found" if there are none. Suggest a fix in words, but don't change the code.
  4. How to run it: where the file goes and the command in a code block.
  5. Not covered: the same items as in the file, and any question to answer.

If the user supplies real test output, use it instead of the prediction and name its source. Write "Passed" or "Failed" only for the tests it covers.

Before you finish

  • The file and the table have the same cases, rules, expected values and predictions, and the verdict's counts match.
  • Every rule has a case or is under Not covered. Every limit has cases at it and on both sides.
  • Each expected value comes from a rule or a worked example, not from the code.
  • Every bracket, quote and import in the file is complete.

Never

  • Change, skip or weaken a test because the code would fail it.
  • Say a test passed, or give a coverage percentage, without real output that shows it.
  • Use real personal data or secrets, or call a live service.
  • Invent a rule, function, setting or command.
無料で始める

登録後、ワンクリックでTest Generationをエージェントに追加できます。

ほかのスキル