unit-testing - MSTest 中的 PublicForTests 注释

标签 unit-testing testing mstest

据我所知,在JUnit中我可以为逻辑测试设置@PublicForTests注解。
我试图在 MSTest 中找到替代方案,但没有成功。

我发现有人说我不需要测试私有(private)方法。
检查我的私有(private)方法逻辑的替代方法是什么?

最佳答案

根据我们的评论,您可以采用两种主要方法来测试私有(private)方法:

  • 第一种是通过使用它的公共(public)方法间接测试您的私有(private)方法。
  • 第二种是通过反射直接测试你的私有(private)方法。

关于unit-testing - MSTest 中的 PublicForTests 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57410345/

相关文章:

visual-studio-2010 - 加载 some.dll : Unable to load the test container 'e:\some.dll' or one of its dependencies 时出错

c# - 使用 Web API 对 JWT token 进行单元测试

c# - 升级到 3.9 版后无法启动 Selenium IE 驱动程序

iOS 单元测试 : how to handle completion of tests?

javascript - 如何测试函数是否使用 async 关键字调用

r - 如何检验所有样本组合是否存在显着差异?

c# - 最小起订量与 lambda 表达式?

java - Hibernate:用另一个文件覆盖xml配置文件

c# - 神秘 : my custom C# attribute is used once, 但在运行单元测试时构造了无数次。为什么?

.net - 使用基类进行单元测试设置和拆卸