How do you unit test private methods?

前端 未结 30 1501
无人及你
无人及你 2020-11-22 06:44

I\'m building a class library that will have some public & private methods. I want to be able to unit test the private methods (mostly while developing, but also it coul

30条回答
  •  攒了一身酷
    2020-11-22 07:25

    On CodeProject, there is an article that briefly discusses pros and cons of testing private methods. It then provides some reflection code to access private methods (similar to the code Marcus provides above.) The only issue I've found with the sample is that the code doesn't take into account overloaded methods.

    You can find the article here:

    http://www.codeproject.com/KB/cs/testnonpublicmembers.aspx

提交回复
热议问题