你如何单元测试的私有方法? [英] How do you unit test private methods?

查看:144
本文介绍了你如何单元测试的私有方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个类库,会有一些公共和放大器;私有方法。我希望能够单元测试的私有方法(主要是在开发,但也可能是为未来重构有用)。

I'm building a class library that will have some public & private methods. I want to be able to unit test the private methods (mostly while developing, but also it could be useful for future refactoring).

什么是做这种正确的方法是什么?

What is the correct way to do this?

推荐答案

您应该使用<一个href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx"相对=nofollow> InternalsVisibleToAttribute 。

这篇关于你如何单元测试的私有方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆