Free AI
Prompt Library
BUILD / FREE PROMPT

Choose tests from a function’s contract

Function, expected behavior, boundary rules and testing framework.

Inputs & setup What you need before copying

Bring: FUNCTION; CONTRACT

Start here: Use a working copy and preserve existing changes. If file or test access is unavailable, request a proposed patch or review rather than claimed execution.

← Build collectionCopy · Add your context · Refine

What you need: Function, expected behavior, boundary rules and testing framework.

Before you start: Use a working copy and preserve existing changes. If file or test access is unavailable, request a proposed patch or review rather than claimed execution.

Best for: Coding & development

Use this prompt with: A text assistant that supports your inputs.

Choose a tool that supports the files or features listed above.

Example result

Sample input

Shipping is free when subtotal is at least 50; otherwise 5. Subtotal cannot be negative.

ILLUSTRATIVE SAMPLE RESULT

Cases: 49.99 → 5; 50 → 0; 50.01 → 0; 0 → 5; −1 → the specified validation error. The 50 case detects an accidental 'greater than' condition. Assert the contract's error behavior rather than accepting whatever the implementation happens to do.

YOUR STARTING POINT
Make it yours Fill in your details

Optional. Your details stay in this browser tab.

Read full prompt
Write tests for [FUNCTION] from [CONTRACT], not by copying its implementation. Cover normal input, boundaries, invalid input and known failure modes. Explain what regression each case catches. Use the existing framework. Execute when available and report results honestly; do not add tests that only repeat the code's current output.

Try a variation 1 ideas

After your first result, try one of these follow-ups.

  • Adapt this result to my supplied constraints. List the missing information before making assumptions.
Check your result
  • Include a boundary case that would fail for a plausible wrong implementation.
Where do I use this prompt?

Copy it into ChatGPT, Claude, Microsoft Copilot.

Follow the simple guide →

Weekly prompts & AI news

Useful prompts, fresh image ideas and AI updates. One email a week.

Subscribe to our weekly newsletter. Unsubscribe anytime. Privacy · Open signup form ↗

A LITTLE INSPIRATION, EVERY WEEK

Your next great AI idea
starts here.

Get useful prompts, fresh image ideas and AI news. Free, once a week.

Subscribe to our weekly newsletter. Unsubscribe anytime. Privacy · Open signup form ↗