Running unit tests on nested functions

后端 未结 6 2038
野的像风
野的像风 2020-12-16 17:32

I come from the Java world, where you can hide variables and functions and then run unit tests against them using reflection. I have used nested functions to hide implement

6条回答
  •  粉色の甜心
    2020-12-16 18:01

    I don't think that there is any chance to access inner() from the extern namespace.

    However, in my opinion the fact that you keep inner() nested implies that the only "contract" that really matters is outer()'s one. inner() is part of the implementation, and you shouldn't want to test the implementation. If you really want to test inner(), do extensive tests on outer() with data that will involve all the functionalities of inner().

提交回复
热议问题