ringa_lee2017-04-17 13:09:31
Of course you can do it. However, if you do this, the unit test will depend on the implementation of your class instead of the interface, thus failing to achieve test as a specification and test driven development. purpose. In the future, although the function and interface of your class will not change, the implementation will change, and the last function of unit testregression test will be lost. Then why do you still write unit test?
It is recommended that the subject read "xUnit Test Pattern" (do not read the Chinese version). Although it is not C++, it is consistent in spirit.