Unit Testing – Advancing Code Review and Unit Testing Practices

code-reviewsunit testing

As a team lead managing a group of developers with no experience ( and see no need) in code review and unit testing, how can you advance code review and unit testing practice?

How are you going to create a way so that code review and unit testing to naturally fit into the developer's flow?

One of the resistance of these two areas is that "we are always tight on dateline, so no time for code review and unit testing".

Another resistance for code review is that we currently don't know how to do it. Should we review the code upon every check-in, or review the code at a specified date?

Best Answer

Do your team members actually agree that code reviews and unit testing are Good Things, just there is no time for these?

Or do they just try to reject the idea with this excuse?

In the first case, the solution is to Start Doing It Now. (OK, if you are in the last days before a major milestone, maybe you can wait until after - but no more.) We had that situation in a previous workplace of mine, where I was Quality Engineer, responsible for improving coding practices and overall quality. We kept deferring the start of code reviews till next week. One day I realized we have been doing this for a month or so, and probably will be continuing till the end of times unless I try something different. So I announced the first code review for that week. I told the guys "no problem if it will be imperfect, or if we don't exactly know what to do yet - we will just start doing it, see how it goes and improve things as we learn". It worked, at least until I left the company.

In the second case, you may need more education and open discussion with the team. Discuss code quality issues, ask them what they see as problems in the development process (or lack thereof) / in the code / testing etc. And brainstorm together about how to resolve these. The ultimate aim is not necessarily to do code reviews - they are just means, while the goal is to improve the development process and the quality of its output. It may well turn out that there are other, more painful issues which could be improved easier, bringing more benefit faster; then take these first. They can even be trivial changes in the environment or the process; all of these will improve team morale, build mutual trust and help the team bond.

The bottom line is, you can't force quality upon anyone - you can only remove the obstacles of creating quality. By enforcing strict rules and mandatory practices without prior team consensus, you may alienate the team and ultimately prevent the quality improvement you are aiming for. OTOH by open discussion and aiming for agreement on what the most pressing problems for the team are and how to improve the situation, you are more likely to get team support. This will make a crucial difference in keeping up the quality improvement drive in the long run.