.net - Nunit Gui 测试结构中的分组方法

标签 .net vb.net unit-testing nunit

目前我有 nunit 的 gui 测试结构设置来使用自动命名空间套件。

我想知道是否可以在 TestFixture 中对方法名称进行分组。

此时,树看起来像

MyClassTest
 +Method-1 test1
 +Method-1 test2
 +Method-1 test3
 +Method-2 test1...

我想知道是否可以让树看起来像

MyClassTest
 +Method1
   ++Method-1 Test1
   ++Method-1 Test2
   ++Method-1 Test3
 +Method2
   ++Method-2 Test1

我为什么要这样做?这是因为我只想选择“Method-1”节点并让它运行该方法的所有测试。我只是省去了检查该方法的所有测试的问题。

背景:使用 vb.net 和 vs2010 pro。

编辑:如果我在“Myclass”中创建一个名为“Method1”的类,我会得到以下内容

MyClassTest
 +Method-2 test1
MyCalssTest+Method-1
   +Test1
   +Test2

最佳答案

我通过创建一个 Method1 测试装置类并将 Method1Test1、Method1Test2 等测试函数作为该类的成员来实现此目的。例如。 (在 C# 中)

[TestFixture]
public class Method1
{
    [Test]
    public void Method1Test1()
    {
       ... 
    }

    [Test]
    public void Method1Test2()
    {
       ... 
    }
} 

关于.net - Nunit Gui 测试结构中的分组方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4804621/

相关文章:

.net - 在调试和 Release模式下构建的 .NET 程序集之间的性能差异?

vb.net - Excel 公式中基于数组的数学运算

c++ - 如何在多个单元测试中使用用户输入变量?

c# - 重试 Visual Studio C# TestMethod

unit-testing - 什么是测试纯函数的更好方法?

c# - 将经典 ASP 应用程序转换为 ASP.NET 有哪些有用的策略

c# - 如何为 FileHelpers 元素类的字段定义默认值

c# - 什么是NullReferenceException,如何解决?

c# - ConcurrentBag的性能,多次读取,罕见的修改

arrays - 检查属性是否是数组