1 of 3
Liath
  • 3.4k
  • 1
  • 21
  • 33

Unit Tests should be submitted in the same PR as the code they test. Or, to phrase it a different way submitted code should not be accepted without an agreed* level of unit testing.

Going back and adding tests later is a myth, it never happens. To use a popular analogy you wouldn't ask a car mechanic to replace your breaks and then book a further appointment for them to test the breaks were fitted correctly!

The only exception to this is when you are adding tests to a previously written piece of code (I know I said it never happens in reality but maybe it's pre-refactor or something). This this case you can submit tests in a PR without code. However that is because there's no code, not because the two have been split out into different PRs.

It's also worth noting that Unit Tests make PRs easier because the reviewers can see the passing tests/scenarios rather than trying to visualise how the code will behave in certain scenarios.

*the level of Unit Testing required will depend on the team/project.

Liath
  • 3.4k
  • 1
  • 21
  • 33