“I’ll add tests in an upcoming PR.” When I hear this, I push back


“I’ll add tests in an upcoming PR.”

When I hear this, I push back. Here's why.

- Tests make the PR easier to review to understand. Tests are documentation. Tests document the developer's intent.

- Tests accelerate code review. I can run the tests to see the intended behavior.

- Tests encourage both the developer and the reviewer to consider potential edge cases.

- Tests assure the code works as expected *before* merge.

- Tests avoid repeated manual tests during development, which saves time.

- Tests exercise the API, which helps expose opportunities for improvement.

- Tests provide regression protection. This supports and encourages continuous refactoring during development.

So, I write tests *before* merge, not after.
Oh yeah, and the biggest reason - after merge, it's far less likely the tests will be written at all.

View original on X