Test Go code with tables, fuzzing and benchmarks

8 steps · about 4 h 10 min · Intermediate

  1. Write focused I/O test cases (reference, Go package documentation, 25 min)

    Purpose-built readers and writers establish observable boundary behaviour.

  2. Test file-system invariants (reference, Go package documentation, 35 min)

    A test file system creates boundary cases without machine-specific fixtures.

  3. Understand how the Go test command runs packages (reference, Go package documentation, 40 min)

    The command contract explains selection, caching and execution of test binaries.

  4. Keep tests at the package boundary (guide, Go documentation, 20 min)

    Understanding packages prevents tests from depending on accidental working-directory state.

  5. Run tests with diagnostic flags (reference, Go command documentation, 30 min)

    Race, count and timeout settings make concurrency failures easier to expose.

  6. Use coverage to find untested behaviour (reference, Go command documentation, 30 min)

    Coverage points to missing paths without becoming the quality goal itself.

  7. Check properties across generated values (reference, Go package documentation, 30 min)

    Generated values make invariant failures easy to reproduce from a small testing API.

  8. Profile benchmarked code (reference, Go package documentation, 40 min)

    Benchmarks and profiles connect a performance claim to measured work.