SnipTray logo
Coding

Write tests for this

Cases that could actually fail, not coverage theatre.

  • testing
  • unit tests
  • edge cases

The prompt

Write {{framework}} tests for the code below.

Before writing them, list the cases where this code could plausibly be wrong —
boundaries, empty and single-element inputs, ordering, concurrent access, error
paths. Then write a test per case, named after the behaviour it protects rather
than the method it calls.

Skip tests that only restate the implementation. If a case cannot be tested
without changing the code, say which change would make it testable.

{{code}}

What to fill in

{{framework}}
Test framework — e.g. XCTest
{{code}}
Code under test — e.g. Paste the function or type

117 prompts, in the app you already paste from

The whole library, searchable, with your own prompts alongside it. Free to browse here; Pro to keep them a keystroke away on every device.