Keep your Source Close and your Unit Tests Closer

后端 未结 7 501
既然无缘
既然无缘 2021-01-03 05:12

When I first started using unit tests I encountered two problems. First was being able to test private methods and fields and second falling behind on keeping unit tests up

7条回答
  •  轮回少年
    2021-01-03 05:39

    I find that keeping my unit tests in their own assembly works very well, and haven't run into any problems using it.

    However, if you find yourself needing to test private members of some class, that probably means your class is doing a lot of stuff. You may be better off extracting those private members into a new class. Then you can test that new class directly via its public methods.

提交回复
热议问题