testing an internal class

后端 未结 6 883
北荒
北荒 2020-12-10 19:10

how to write unit tests to internal classes ???

6条回答
  •  Happy的楠姐
    2020-12-10 19:39

    We have used a helper class which uses reflection to load and call methods on internal classes. It is also possible to change the accessibility at compile time using the DEBUG symbol eg

    #if DEBUG
    public
    #else
    internal
    #endif
        class MyInternalClass
    {
        ...
    }
    

    However Esko Luontola's answer is more correct as it is the functionality or business requirements which are most important. It is easy to get too focused on code coverage rather than testing the important risk areas.

提交回复
热议问题