你怎么测试与NUnit的私有方法? [英] How do you test private methods with NUnit?

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

问题描述

我想知道如何正确使用NUnit的。首先,我创建了一个使用我的主要项目作为参考单独的测试项目。但在这种情况下,我无法测试私有方法。我的猜测是,我需要包括我的测试code到我的主要code? - 这似乎并没有被这样做的正确方法。 (我不喜欢运费code在它测试的想法。)

I am wondering how to use NUnit correctly. First i created a separate Test-Project that uses my main project as reference. But in that case i am not able to test private methods. My guess was that i need to include my testcode into my main code?! - That doesn't seem to be the correct way to do it. (I dislike the idea of shipping code with tests in it.)

如何与NUnit的测试私有方法?

How do you test private methods with NUnit?

推荐答案

一般来说,单元测试解决一类的公共接口,理论上的实现并不重要,只要结果是从客户端查看的观点是正确的。

Generally, unit testing addresses a class's public interface, on the theory that the implementation is immaterial, so long as the results are correct from the client's point of view.

所以,NUnit的不测试非公共成员提供任何机制。

So, NUnit does not provide any mechanism for testing non-public members.

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

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