Full disclosure, I asked ChatGPT “list 10 controversial conversation starts for software testers”, and this was number two on the list:
Do you think developers should be responsible for testing their own code? What are the potential risks and benefits?
I think this is a fascinating question, because there are a number of myths it alludes to. One is that “Devs shouldn’t test their own code, it’s like marking your homework”. This is wrong on so many levels, not least because before handing in work to be marked, it’s very good exam or assignment technique to proof read, and critically assess your own work.
I think the risks of developers not testing their own code, is that they will very easily build the wrong thing, or miss many classes of bugs they could have designed out early, leading to very expensive and repetitive cycles of bug fixing.
But hang on, do any developers really not test their own code, AT ALL? I seriously doubt it, although they may have different names for it, and they likely don’t formally record it.
So, I’ve got some better questions, and some opinions from myself:
- Should the primary developer for some code be the only one to test it?
I think this comes down to experience and risk. Is the developer experienced testing their own code, and overcoming the obvious blindnesses to work you’re close with? What is the risk, if the code is released unchecked, and makes its way to production?
It maybe the developer is experienced, or even if they are not, the code maybe in a low risk environment, where rollbacks are trivial or downtime is not important. Maybe automated checks are also very strong.
Realistically, it is a very good idea to get the code tested by some other humans, although this might also be done through pairing or ensemble practices, rather then after the fact.
- Must all code be tested by someone else before it is deployed?
Again, this comes down to risk, it is a jolly good idea most of the time.
- Can developers learn how to test their own code better, such that we reduce the need for external testing
100% I know this to be true, I’ve worked with developers who have build up testing skills and do effective testing on their own code. This becomes even more powerful when used with pairing or working in an ensemble, either with other developers or with skilled testers.
So, to come back to the question, do I think developers should be responsible for testing their own code?
I think developers should be testing their own code, I think the responsibility for the code, and it’s quality, should be shared across the team, ideally a team that includes at least one person who is highly skilled in testing.