Java Test Design

Writing a Java test that survives refactoring and says why it failed: naming the behaviour rather than the method, one reason to fail, test data builders over shared mutable setup, choosing the assertion that produces a readable failure, parameterised and nested tests, and removing every input the test does not control — clock, ordering, locale, randomness. Use when a test name does not say what broke, when a failure message has to be decoded by reading the test, when setup is shared across unrelated tests, when a test sleeps, when tests pass alone and fail together, when a flaky test is about to be retried or disabled, or when the same assertions are being copied across cases. Does not cover which level to test at (java-testing-strategy), stubs and mocks (java-test-doubles), the red-green-refactor loop (tdd), or threading (concurrency-testing).

robsonkades d9ffa94 4 files · 21.1 KB Updated

File contents

robsonkades/agent-skills/tree/main/skills/java-test-design commit d9ffa94243

Frequently asked questions

npx skillmds@latest add robsonkades/java-test-design