NUnit/TestDriven(产品,而不是方法论),是否可以默认忽略一类测试?

发布于 2024-10-27 07:25:47 字数 333 浏览 0 评论 0原文

我们正在使用 NUnit 定义自动化性能测试。然而,由于其中许多将运行一段时间,为了解决系统上的计时和负载不准确的问题,我们不希望开发人员必须在正常开发下运行这些。

有什么方法可以指示 TestDriven Visual Studio 插件忽略一组单元测试,这样如果程序员只需右键单击单元测试项目并选择“运行测试”,这些测试就不会执行?

似乎默认情况下忽略测试的唯一方法是通过 [Explicit] 属性,但这意味着我会在测试服务器上产生维护开销,因为似乎没有办法一次性执行所有显式测试而不将它们全部命名。

或者我应该将所有性能测试分离到单独的项目中,并指示程序员不要管它(至少在他们需要更新测试之前)?

We're in the process of defining automated performance tests using NUnit. However, since many of these will run for a bit of time, to cater for inaccuracies in timing and load on the system, we don't want the developers to have to run these under normal development.

Is there any way we can instruct the TestDriven Visual Studio addin to ignore a set of unit tests, so that if the programmer just right-clicks on the unit-test project and selects "Run Tests", those tests are not executed?

It seems the only way to make tests be ignored by default is through the [Explicit] attribute, but that means I incur a maintenance overhead on our test server, since there doesn't seem to be a way to execute all the explicit tests in one fell swoop without naming them all.

Or should I just separate out all the performance tests to its separate project and just instruct the programmers to leave it alone (at least until they need to update the tests) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

幸福%小乖 2024-11-03 07:25:47

我会创建一个单独的测试程序集。然后,您可以在一个程序集中进行正常的单元测试,并在第二个程序集中进行性能测试。

这样,在开发时开发人员就不会运行性能测试。在构建时,您可以执行两个测试程序集以确保 Unit 和运行性能测试。

我这样做不仅是为了不必运行某些测试,而且它可以更好地区分该程序集中的内容。这个新程序集不是一组“单元”测试。当你引入新的开发人员时,你们编写测试的方式不会有任何混乱。您不希望新人看到性能测试并认为这就是编写单元测试的方法。

至于具体问题,请让 TestDriven 避免运行性能测试,检查“工具->选项”下的设置对话框:

 TestDriven.NET 选项

I would create a separate testing assembly. Then you can have your normal unit tests in one assembly and performance tests in a second assembly.

That way, at development time the developers never run the perf tests. At build time you could execute both test assemblies to make sure that both Unit & Perf tests are run.

I would do this not just so that some tests wouldn't have to get run, but it offers a better distinction of what's in that assembly. This new assembly isn't a set of "Unit" tests. And as you bring new devs on, there wouldn't be any confusion to how you guys write tests. You wouldn't want a new guy looking at a perf test and thinking that's how to write unit tests.

As for the concrete question, ask TestDriven to avoid running your performance tests, check the settings dialog under "Tools->Options":

TestDriven.NET Options

人生戏 2024-11-03 07:25:47

[ignore] 属性怎么样?也许我误解了,但在我看来这对你有用?

What about the [ignore] attribute? Maybe I am misunderstanding, but it sounds to me like this will do the trick for you??

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