Testing Private Method using Pex

我的梦境 提交于 2019-12-11 07:22:56

问题


I want to use Pex and Moles in my project.I want to test Private method using Pex.

Is anyone used Pex to test private method?

If we can't test directly, Is there any workaround to test Private method?


回答1:


This has been answered by Peli, one of Pex's authors: PEX will not work for private and protected methods and workaround pex internal class.

A few of the alternatives:

  1. Don't test private methods.
  2. Re-design the logic you are testing to increase testability.
  3. Use InternalsVisibleToAttribute. Put [assembly: InternalsVisibleTo("Company.Product.ProjectUnderTest.Tests")] into Company.Product.ProjectUnderTest\Properties\AssemblyInfo.cs.

testing .net



来源:https://stackoverflow.com/questions/8613263/testing-private-method-using-pex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!