Testing and Debugging

  1. Choosing Boundary Test Cases

    A boundary test checks the values at and immediately around a place where the intended outcome changes.

    Undergraduate
  2. Reproducing an Ordinary Program Bug

    A useful reproduction specifies the initial state, exact input, observed behavior, and expected outcome for a single defect.

    Undergraduate
  3. Finding a Smaller Failing Input

    Reduce a failing input by removing features whose presence is unnecessary for observing the same defect.

    Undergraduate
  4. Separating Setup, Action, and Assertion in Tests

    A test is easier to review when it establishes useful state, performs one operation, and checks the behavior that operation promises.

    Undergraduate
  5. Making Test Inputs Explain Themselves

    A test's values should make its assumed units, boundary, and expected result apparent to a reader.

    Undergraduate
  6. Table-Driven Tests

    A table-driven test enumerates inputs and expected outcomes in rows while sharing one execution and assertion procedure.

    Undergraduate
  7. Independent Tests and Fresh Fixtures

    Tests should establish the state they rely on so running one case independently produces the same outcome as running the suite.

    Undergraduate
  8. Using Assertions to Debug Data Flow

    A debugging assertion records an expected property at a point where a wrong value can still be connected to its cause.

    Undergraduate
  9. Stepping Through Calls in a Debugger

    A debugger can continue over a call as one step, enter it to inspect parameters, or run until its current frame returns.

    Undergraduate
  10. Unit Tests and Integration Tests

    A unit test checks a focused component's behavior. An integration test exercises a boundary between cooperating components.

    Undergraduate
  11. Writing a Regression Test for a Fixed Defect

    A regression test uses input that once failed and asserts the observable behavior supplied by the fix.

    Undergraduate
  12. Testing Time-Dependent Code with a Fake Clock

    A fake clock supplies controlled times to a routine so a test can cross a deadline without sleeping or changing the system time.

    Undergraduate
  13. Testing a Reader with In-Memory Input

    An in-memory input can exercise parsing behavior while avoiding files when the reader accepts a stream or iterable.

    Undergraduate
  14. Capturing Output in a Test

    Capture output when writing text is part of the public behavior. Inspect return values directly when they carry the result.

    Undergraduate
  15. Property Tests for Sorting

    A sort can be tested over generated lists by checking order and preservation of multiplicities independently.

    Undergraduate
  16. Round-Trip Tests for Encoders and Decoders

    A round-trip test encodes a value and decodes the result to verify that the intended information survives.

    Undergraduate
  17. Metamorphic Tests with Related Inputs

    A metamorphic test checks how an output should change when the input undergoes a known transformation.

    Undergraduate
  18. Specifying Tolerances in Numeric Tests

    An approximate test needs a tolerance derived from the input units, expected scale, and error budget of the computation.

    Undergraduate
  19. Recording Random Choices in Tests

    A randomized test should preserve a failing example or enough information to reproduce it under the stated environment.

    Undergraduate
  20. Choosing Context for Diagnostic Logs

    A diagnostic message is useful when it connects a relevant operation with the observed state and a clear result.

    Undergraduate
  21. Detecting Order Dependence in Flaky Tests

    A flaky test can depend on prior state, timing, environment differences, or nondeterministic execution. Narrow the cause with deliberate changes.

    Undergraduate
  22. Naming Tests by Scenario and Outcome

    A useful test name states the situation and the expected behavior so a failure can be understood outside the file.

    Undergraduate
  23. Testing an Expected Exception

    Check the promised exception near the exact operation that should raise it. Preserve enough context to distinguish it from unrelated failures.

    Undergraduate
  24. Statement and Branch Coverage

    Coverage indicates which code ran during tests. Branch coverage checks whether the alternatives of a decision were traversed.

    Undergraduate
  25. Choosing a Hand Trace or a Debugger

    A hand trace focuses attention on a few values. A debugger can inspect the program's actual state where a larger calculation becomes surprising.

    Undergraduate
  26. Testing Stable Output Against a Reference File

    A reference file records an approved, representative output so accidental formatting or content changes become visible.

    Undergraduate
  27. Testing Sequences of State Transitions

    A stateful test exercises several events in order and verifies which effects persist across the events.

    Undergraduate
  28. A Good Test Distinguishes Plausible Wrong Results

    Choose an input for which a realistic implementation mistake gives a different result from the promised behavior.

    Undergraduate
  29. Triaging Several Test Failures

    Several failures can share a faulty dependency or setup assumption. Find the earliest useful evidence before editing each failing case.

    Undergraduate
  30. Using Synthetic Data in Tests

    Synthetic test records keep real personal information out of source files, test output, and review systems.

    Undergraduate