对我来说,对必须从 ASP.Net 和 WinForms 使用的库进行 nunit 测试的最佳位置是什么
我有一个必须在 WinForms 和 ASP.Net 中使用的基础结构库。
我想将其包含在一些单元测试中。
我要把这些放在哪个项目中?
我是否在库项目中使用其他文件夹? 一个仅包含我的基础设施项目和一个单独的单元测试项目的不同解决方案?
顺便说一句,我将使用 ReSharper 测试运行程序,如果这有什么区别的话。
另外,这个库位于 NHibernate 之上,如果这也有什么区别的话。
I have an infrastructure library which must be used from both WinForms and ASP.Net.
I would like to wrap this up in some unit tests.
Which project do I put these in?
Do I use another folder in my library project?
A different solution which contains only my infrastructure project and a separate unit testing project?
Incidentally, I will be using the ReSharper test runner, if that makes any difference.
Also, this library sits on top of NHibernate, if that makes any difference either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将创建一个仅包含您的测试的单独项目。 从测试项目中引用您的基础设施项目。
将生产代码与单元测试一起发布没有多大意义,即使它们不是通过 winform 或 Web 界面访问的。
此外,考虑使用 MVP 架构模式和依赖注入来组织您的类,并使您的演示者和其他组件更加易于测试。
I would create a separate project containing only your tests. Reference your infrastructure project from the testing project.
It doesn't make much sense to ship your production code out with your unit tests, even if they are not accessed via the winform or web interface.
Additionally, consider using MVP architecture pattern with Dependency Injection to organize your classes and make your presenter and other components more test friendly.
将测试完全放在一个单独的项目中,然后您可以将该项目包含在 WinForms 解决方案和 ASP.NET 解决方案中。
Put your tests in a separate project altogether, and you can include that project in your WinForms solution and your ASP.NET solution.
我不仅为我的测试创建一个单独的项目,还进一步将它们划分为单独的项目以进行单元测试和集成测试。
通过这种方式,您可以将持续集成服务器配置为仅在签入时运行单元测试,然后为夜间构建运行两组测试。
I not only create a separate project for my tests, I further divide them into separate projects for unit and integration tests.
This way you can configure your continuous integration server to only run the unit tests on check in, and then run both sets of the tests for the nightly build.