是否认为不好的做法使用InternalsVisibleTo单元测试code?单元测试、做法、不好、InternalsVisibleTo

2023-09-03 03:10:56 作者:网名由于太个性已被屏蔽

样品code框架的的AssemblyInfo.cs

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo
                          ("Test.Company.Department.Core")]

这是一个不好的做法?

推荐答案

没有,它不被视为不好的做法。有没有别的办法,如果你想测试这些类是内部的组件很好的理由。只是没有测试他们会差很多。

No, it is not considered bad practice. There is no other way, if the classes you want to test are internal to your assembly for good reasons. Just not testing them would be a lot worse.