Nunit - 如何跳过测试设置以调用特定的单元测试用例 [英] Nunit - How to skip test setup to call for particular unit test case

查看:43
本文介绍了Nunit - 如何跳过测试设置以调用特定的单元测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 unittest case 项目,其中 TestSetup 是为所有测试文件全局设置的.

I have unittest case project where TestSetup is globally setup for all test files.

[SetUpFixture]
public class TestSetup
{
     [Setup]
     public TestSetupMethod(){}
}

如何跳过测试设置以调用特定的 nunit 单元测试用例.所有其他单元测试用例都需要这个,但对于几个不需要的单元测试用例.

How to skip test setup to call for particular nunit unit test case. all other unit test case need this but for couple of unit test case where it is not require.

推荐答案

来自 文档:

这是标记一个类的属性,该类包含给定命名空间下所有测试装置的一次性设置或拆卸方法.

This is the attribute that marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace.

因此,只需在设置类的命名空间中添加所有需要一次性设置的单元测试,所有不需要在另一个中进行设置的单元测试.

So simply add all unit tests that requires the one-time setup in the namespace of your setup class, all that don't require that setup in another.

这篇关于Nunit - 如何跳过测试设置以调用特定的单元测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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