Obscure Test

Tests that are hard to understand.

Meszaros, xUnit Test Patterns

Signs of Use (Symptoms)

  • Verification logic is complex and spread across many lines.
  • Test names don’t describe what’s being tested.
  • Excessive setup code.

Refactoring Solution

  • Use clear, descriptive test names.
  • Extract helper functions for setup.
  • One assertion per test (or closely related assertions).

Code example

Bad

Good