NUnit & Visual Studio 单元测试框架
有没有办法创建可以使用 Visual Studio 单元测试框架 运行的单元测试作为NUnit?我个人更喜欢 Visual Studio,但我使用的构建服务器只支持 NUnit,所以如果可能的话我想同时支持两者。
编辑:为了澄清,我想使用 Visual Studio 运行我自己的测试(没有附加组件或扩展),但其他同事想使用 NUnit,并且构建服务器需要 NUnit。除了代码之外,我无法更改任何内容,因此我认为有一种简单的方法可以满足每个人的需求,但这看起来有点挑战:)
Is there a way to create unit tests that can be run with the Visual Studio Unit Testing Framework as well as NUnit? I personally prefer the Visual Studio one, but the build server I am using only does NUnit, so I would like to support both if possible.
EDIT: To clarify, I would like to run my own tests using Visual Studio (without add-ons or extensions), but other collegues would like to use NUnit, and the build server needs NUnit. I cannot change anything except the code, so I thought there would be an easy way to satisfy everyone, but its looking to be a bit of a challenge :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您需要一个 Visual Studio 测试运行程序。如果您安装 Gallio,它将使用 VS 测试运行器来运行任何类型的单元测试(xUnit、 nUnit、MBUnit)。还有 Resharper 和 CodeRush 有自己的测试运行程序。
Sounds like you need a Visual Studio test runner. If you install Gallio, it will use VS test runner to run any kind of unit tests(xUnit, nUnit, MBUnit). Also Resharper and CodeRush have their own test runners.
这是一种方法,通过“使用预编译器指令和别名”使用“关键字
Here is one way to do that using precompiler directives and aliases via the "using" keyword
JustCode 有一个单元测试运行程序,可以运行使用 xUnit 编写的测试、NUnit、MbUnit 或 Visual Studio 单元测试框架。您可以在此处查看它的实际效果
JustCode has a unit test runner that can run tests written using xUnit, NUnit, MbUnit, or Visual Studio Unit Testing Framework. You can see it in action here
您可以使用名为 Should 的库编写与框架无关的断言。它还具有非常好的流畅语法,如果您喜欢流畅的界面,可以使用它。我有一篇与此相关的博客文章。
http://nileshgule.blogspot.com/2010 /11/use-should-assertion-library-to-write.html
You can write framework agnostic asserts using a library called Should. It also has a very nice fluent syntax which can be used if you like fluent interfaces. I had a blog post related to the same.
http://nileshgule.blogspot.com/2010/11/use-should-assertion-library-to-write.html