C++ Unit Test and Dependency Injection
TDD (test driven development) is widely adopted in modern development such as web development. Because it allows the developers to test the solution robustly in order to produce a more stable product.
Higher level programming languages like JavaScript and Ruby allows the developers to easily mock the functions and data to test the target specification. However, programming language like C++ is not designed for TDD. It will be more complex if you want to mock functions.
Unit testing and TDD
- I was thinking, WT* is the unit test?
- Why should I need unit test?
- Why should I spend my time to prepare the test cases?
- Why should I spend my time to become a tester instead of a developer?
For the first question, if searching online, what you get are just bunch of almost useless information. They can let you get high score in exam.
For the second question, instead of answering why, I will say, it depends. It depends on the language you are using and the framework that you are using. Let’s say you are working on C programming, there is less support of unit testing library. If you are working on Linux kernel development, unit test is difficult to implement. But, if you are developing web application, then unit testing and other testings are highly recommended. Why? Let me go to the next two answers beforehand.