NUnit & Visual Studio 单元测试框架

发布于 2024-09-25 00:58:53 字数 411 浏览 1 评论 0原文

有没有办法创建可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

趁年轻赶紧闹 2024-10-02 00:58:53

听起来您需要一个 Visual Studio 测试运行程序。如果您安装 Gallio,它将使用 VS 测试运行器来运行任何类型的单元测试(xUnit、 nUnit、MBUnit)。还有 ResharperCodeRush 有自己的测试运行程序。

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.

默嘫て 2024-10-02 00:58:53

这是一种方法,通过“使用预编译器指令和别名”使用“关键字

Here is one way to do that using precompiler directives and aliases via the "using" keyword

-柠檬树下少年和吉他 2024-10-02 00:58:53

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

又爬满兰若 2024-10-02 00:58:53

您可以使用名为 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文