【发布时间】:2011-12-23 07:13:23
【问题描述】:
我想在我的项目中使用 Pex 和 Moles。我想使用 Pex 测试 Private 方法。
有人用 Pex 测试私有方法吗?
如果不能直接测试,有什么办法可以测试私有方法吗?
【问题讨论】:
-
标志被移除,请参考FAQstackoverflow.com/faq#signatures
标签: pex
我想在我的项目中使用 Pex 和 Moles。我想使用 Pex 测试 Private 方法。
有人用 Pex 测试私有方法吗?
如果不能直接测试,有什么办法可以测试私有方法吗?
【问题讨论】:
标签: pex
Pex 的作者之一Peli 已回答此问题:PEX will not work for private and protected methods 和 workaround pex internal class。
一些替代方案:
InternalsVisibleToAttribute。将[assembly: InternalsVisibleTo("Company.Product.ProjectUnderTest.Tests")] 放入Company.Product.ProjectUnderTest\Properties\AssemblyInfo.cs。【讨论】: