I think he was very surprised with my response: "You don't need to test that."
Tests should not be written to check implementations, but only when over a certain threshold of complexity; They should be written to test API contracts (respect preconditions, then check postconditions, invariants, and side effects).
If the current implementation is trivial, tests should still be written to respect preconditions, then check postconditions, invariants, and side effects.
The complexity of the implementation (for deciding if the test should be written) is a red herring.
That said, I too sometimes (many many sometimes) skip writing tests because the implementation is trivial.
1
u/utnapistim May 09 '17
Tests should not be written to check implementations, but only when over a certain threshold of complexity; They should be written to test API contracts (respect preconditions, then check postconditions, invariants, and side effects).
If the current implementation is trivial, tests should still be written to respect preconditions, then check postconditions, invariants, and side effects.
The complexity of the implementation (for deciding if the test should be written) is a red herring.
That said, I too sometimes (many many sometimes) skip writing tests because the implementation is trivial.