I am debating with my colleague on when to perform code review – before or after unit tests. What is the best practice?
Some factors we might need to take into account (there may be more):
- Size of code change – a big change means more changes will result from the code review. If these changes are big than, if UT was before code review, you'll need to repeat most of your UTs again.
- Time required to perform unit test
- Is it new functionality or a bug fix
Best Answer
You should always unit test before doing the code review and here's why
There are probably other reasons but those are the ones I've personally seen and experienced having implemented code review practices within 3 different teams/companies.
Edit Of course the above is for times when code review is a step in your software development process (whether waterfall or agile). If you're working on a particularly large or difficult section of code feel free to get another pair of eyes on it at any point.