Your company decides to start the business of selling toys online and shipping globally. A team in-house is in charge of developing an E-Commerce system that supports the new business. As code quality is a priority, the development team decides to implement the unit testing. Which of the following is the best strategy in practice?
A. Task the software testing team to write unit testing code for separation of duty
B. Ask developers to write unit testing code before writing production code
C. Request developers to write unit testing code after writing production code
D. Demand the system analysts specify the unit testing specification before writing production code
Kindly be reminded that the suggested answer is for your reference only. It doesn’t matter whether you have the right or wrong answer. What really matters is your reasoning process and justifications.
My suggested answer is B. Ask developers to write unit testing code before writing production code.
Unit testing is writing code to test code, a white box testing. It’s mostly development work as developers know the code logic the best.
It’s almost impossible or impractical to demand system analysts specify the unit testing specification because it’s implementation work and needs unbelievable details.
Since the development team made the decision to implement the unit testing and unit testing is part of the development work, it’s inappropriate to task the software testing team to write unit tests.
As writing unit tests is part of the development work, it should help improve software quality and the productivity of developers, instead of increasing their workload. As a result, it’s cumbersome for developers to write unit testing code after writing production code.
The best way is to conduct the Test-Driven Development (TDD). Developers write unit tests before the production code. However, the threshold and learning curve of TDD is pretty high; only experienced developers can do that well.