2011-01-26 29 views
1

目前我有nunit的gui測試結構設置使用自動命名空間套件。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」稱爲「方法一」,我得到以下

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

回答

2

我通過創建一個Method1測試夾具類和具有Method1Test1,Method1Test2等做到這一點。測試功能作爲該類的成員。例如。 (在C#中)

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

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

我在「Myclass」中創建了一個名爲Method1的新類,而不是樹中「Myclass」節點的子節點;它成爲名爲MyBranch + Method1的姐妹分支。 – Lareau 2011-01-26 13:21:31

+3

使Myclass成爲一個命名空間,並將所有Method1,Method2等類放入其中 - 您將獲得所需的內容。 – 2011-01-26 13:23:49

1

NUnit的Category屬性也可能有幫助。