Prompt Challenges
Code & Dev· Open for solutions

Write Tests Before Implementing a Pricing Rule

Write a reusable prompt with replaceable inputs. Submit your prompt and one test output for this example.

Task: Build a prompt that generates tests from a specification before writing an implementation.

Example input: A fictional function quote_total(quantity, unit_price_cents) calculates an integer total in cents. Quantity must be an integer from 1 to 100; unit price must be a nonnegative integer. Booleans are invalid inputs. A 10% discount applies when quantity is at least 10. Round the discounted line total down to the nearest cent. Add a 500-cent shipping charge only when the discounted line total is below 5,000 cents. Invalid inputs raise ValueError.

Constraints:

  • Produce tests only, without implementing the function.
  • Cover discount and shipping boundaries separately.
  • Show expected values and a brief reason for each case.

Required output from your prompt: A Python unittest test suite assuming the function is imported from pricing.py, plus a boundary-coverage checklist.

Success checks:

  • Tests distinguish quantities 9 and 10.
  • A 5,000-cent discounted subtotal receives no shipping charge.
  • Non-integers, booleans, and out-of-range quantities are rejected.
  • Rounding is tested with a subtotal whose discounted result is fractional.
by Abdul Mohammed0 solutions
No solutions yet — be the first to submit one.
Prompt Challenges

Have the perfect prompt? Submit it.

Open it in Prompt Dock — any creator can link one of their published prompts as a solution.

Submit a solutionSign in to submit — any creator plan, free included.
Free to start

Need a prompt built? Post a challenge.