How do you unit test private methods?

前端 未结 30 1499
无人及你
无人及你 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:47

    Sometimes, it can be good to test private declarations. Fundamentally, a compiler only has one public method: Compile( string outputFileName, params string[] sourceSFileNames ). I'm sure you understand that would be difficult to test such a method without testing each "hidden" declarations!

    That's why we have created Visual T#: to make easier tests. It's a free .NET programming language (C# v2.0 compatible).

    We have added '.-' operator. It just behave like '.' operator, except you can also access any hidden declaration from your tests without changing anything in your tested project.

    Take a look at our web site: download it for free.

提交回复
热议问题