如何订购 NUnit 测试 [英] How to Order NUnit Tests

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

问题描述

在 SO 上不止一次这个问题被问到.但是给出的唯一答案是您不需要订购单元测试,这很糟糕,因为"或如果……,您可以避免这种情况"

More than once the question has been asked on SO. But the only answers that are given read "you should not need to order your unit tests, it is bad because" or "you can avoid that if..."

我已经知道它不好,为什么不好,以及避免它的技巧.但这不是我想知道的.我想知道是否可以对 NUnit 测试的执行进行排序,而不是按字母顺序排列.坦率地说:我实际上希望状态从一个测试传播到下一个.相信我,我有一个聪明的理由,它违背了通常的哲学.

I already know it is bad, why it is bad, and techniques to avoid it. But that is not what I want to know. I'd like to know if it is possible to order the execution of NUnit tests, other than an alphabetical order. To be blunt: I actually want state to propogate from one test to the next. Trust me that I have a clever reason for this, that defies the usual philosophy.

MSTest 具有有序测试"功能,这在某些情况下非常有用.我想在 NUnit 中拥有这种能力.可以吗?

MSTest has the "ordered test" capability, which is very useful in certain cases. I'd like to have that ability in NUnit. Can it be done?

推荐答案

变通方法 (hack) 是按字母顺序排列测试用例名称.看到这个线程:

The work-around (hack) is to alphabetize your test case names. See this thread:

https://bugs.launchpad.net/nunit-3.0/+bug/740539

依靠字母顺序是您可以使用的一种解决方法,但它没有记录和支持超出显示的视觉顺序.理论上它可以随时改变.实际上它在 NUnit 3.0 之前不会改变,所以你可以很安全地使用它作为一种解决方法

Relying on alphabetical order is a workaround that you can use but it is not documented and supported beyond the visual order of the display. In theory it could change at any time. In practice it won't change until NUnit 3.0, so you're pretty safe using it as a workaround

这句话来自 NUnit 的主要开发者 Charlie Poole.

This quote is from Charlie Poole, the main dev on NUnit.

他们似乎也有一个计划来支持 NUnit 3 中的有序测试,但他们将如何做到这一点仍在讨论中.

It also seems they have a scheme cooking to support ordered tests in NUnit 3, though how they will do so is still under discussion.

这篇关于如何订购 NUnit 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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