NUnit Test Run Order(NUnit 测试运行顺序)
问题描述
默认情况下,nunit 测试按字母顺序运行.有谁知道设置执行顺序的任何方法?是否存在此属性?
By default nunit tests run alphabetically. Does anyone know of any way to set the execution order? Does an attribute exist for this?
推荐答案
每个单元测试都应该能够独立运行和独立运行.如果它们满足此标准,则顺序无关紧要.
Your unit tests should each be able to run independently and stand alone. If they satisfy this criterion then the order does not matter.
但在某些情况下,您需要先运行某些测试.一个典型的例子是在持续集成的情况下,一些测试比其他的运行时间更长.我们使用类别属性,以便我们可以在使用数据库的测试之前运行使用模拟的测试.
There are occasions however where you will want to run certain tests first. A typical example is in a Continuous Integration situation where some tests are longer running than others. We use the category attribute so that we can run the tests which use mocking ahead of the tests which use the database.
即把它放在你快速测试的开始
i.e. put this at the start of your quick tests
[Category("QuickTests")]
如果您有依赖于特定环境条件的测试,请考虑 TestFixtureSetUp 和 TestFixtureTearDown 属性,它们允许您标记要在测试之前和之后执行的方法.
Where you have tests which are dependant on certain environmental conditions, consider the TestFixtureSetUp and TestFixtureTearDown attributes, which allow you to mark methods to be executed before and after your tests.
这篇关于NUnit 测试运行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:NUnit 测试运行顺序
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30