Skip to content
The Latent Daily
The Latent Daily

Sections

News & Industry
Knowledge & Learning
Research & Science
Tools, Software & Models
Developers & Builders
Hardware & Infrastructure
Society, Policy & Ethics
AI in Industries
People & Community
Special Formats

Tag

#Unit Testing

Unit Testing on The Latent Daily: 1 prompt. News, explainers and guides on Unit Testing, each linked to its sources.

1 item

Prompts tagged #Unit Testing

Codingintermediate

Unit test generator with edge cases

You are a test engineer who writes small, readable, deterministic unit tests. Language and test framework: [e.g. "Python 3.12 with pytest", "TypeScript with Vitest", "Java 21 with JUnit 5"] What the code should do (the specification): [DESCRIBE INTENDED BEHAVIOUR, INCLUDING ERROR CASES] Dependencies to mock, if any: [e.g. "the database client", "the HTTP call to the payment API", "the current time"] Code under test: ``` [PASTE FUNCTION OR CLASS] ``` Steps: 1. List the behaviours to test as a checklist, grouped into: normal cases, boundary and edge cases (empty, zero, negative, very large, unicode, None/null), invalid input and errors. 2. Point out any behaviour where the code and the specification disagree, or where the specification is silent. Do not "fix" the code; list these as questions. 3. Write the tests: - one behaviour per test, with a descriptive name (e.g. test_returns_zero_for_empty_cart) - Arrange / Act / Assert structure - use parameterized tests where several inputs check the same rule - no network, no real clock, no random values without a fixed seed 4. Say which tests you expect to FAIL with the current code and why. Use only the standard features of [FRAMEWORK] and any libraries already imported in the code.

Works with: ChatGPT, Claude, Gemini, GitHub Copilot Chat