亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > Nunit
NUnit學習筆記
作者:網絡轉載 發布時間:[ 2013/3/20 15:10:20 ] 推薦標簽:
 

    Ignore屬性,忽略測試,可以供類和方法使用,用于忽略暫時不想運行的測試用例。
    示例1:
    VB代碼:
<TestFixture(), Ignore("class test ignore")> _
Public Class Test
<Test()> _
Public Sub TestIgnore()
End Sub
 
<Test()> _
Public Sub TestIgnore2()
End Sub
End Class
    C#代碼:
        [TestFixture]
[Ignore("class test ignore")]
class Test
{
[Test]
public void TestIgnore()
{}
 
[Test]
public void TestIgnore2()
{}
}
    J#代碼:
/** @attribute TestFixture() */
/** @attribute Ignore("class test ignore") */
public class Test
{
/** @attribute Test() */
public void TestIgnore()
{}
 
/** @attribute Test() */
public void TestIgnore2()
{}
}
測試效果:NUnit-GUI狀態條為黃色。
示例2:
VB代碼:
        <TestFixture()> _
Public Class Test
<Test(), Ignore("function test ignore")> _
Public Sub TestIgnore()
End Sub
 
<Test()> _
Public Sub TestIgnore2()
End Sub
End Class
C#代碼:
        [TestFixture]
class Test
{
[Test]
[Ignore("function test ignore")]
public void TestIgnore()
{}
 
[Test]
public void TestIgnore2()
{}
}
J#代碼:
        /** @attribute TestFixture() */
public class Test
{
/** @attribute Test() */
/** @attribute Ignore("function test ignore") */
public void TestIgnore()
{}
 
/** @attribute Test() */
public void TestIgnore2()
{}
}
測試效果:NUnit-GUI狀態條為黃色,但與方法TestIgnore2對應的節點顯示為綠色。由于本例僅忽略了方法TestIgnore,而這并不會影響TestIgnore2,因此TestIgnore2依然會正常運行。
 
    Suite屬性。根據NUnit文檔的說明,Suite屬性是用來標記返回類型為NUnit.Core.TestSuite的類屬性成員的,該類屬性成員所返回的對象會包含一組測試類,也是說Suite屬性其實是用來組織一組測試類的。那么組織這些測試類到TestSuite對象中有何用呢?其實在早期的NUint當中,提供有NUnit.TextUI.TestRunner類,該類有個Run方法,參數是TestSuite對象,通過該方法可以在代碼中調用NUnit環境,從而運行TestSuite對象中的測試類。不過現在NUnit似乎已經不再使用這種方式了,故此對于Suite屬性這里不再介紹。
 
    Category屬性,分組測試,用于將測試類和測試方法分組,從而使測試類和測試方法可以按組進行測試。
    示例:
VB代碼:
<TestFixture(), Category("class1")> _
Public Class Class11
<Test()> _
Public Sub Test()
End Sub
End Class
 
<TestFixture(), Category("class1")> _
Public Class Class12
<Test()> _
Public Sub Test()
End Sub
End Class
 
<TestFixture(), Category("class2")> _
Public Class Class21
<Test()> _
Public Sub Test()
End Sub
End Class
 
<TestFixture(), Category("class2")> _
Public Class Class22
<Test()> _
Public Sub Test()
End Sub
End Class
 
<TestFixture()> _
Public Class Class3
<Test(), Category("function1")> _
Public Sub Test11()
End Sub
 
<Test(), Category("function1")> _
Public Sub Test12()
End Sub
 
<Test(), Category("function2")> _
Public Sub Test21()
End Sub
 
<Test(), Category("function2")> _
Public Sub Test22()
End Sub
End Class
C#代碼:
[TestFixture]
[Category("class1")]
class Class11
{
[Test]
public void Test()
{}
}
 
[TestFixture]
[Category("class1")]
class Class12
{
[Test]
public void Test()
{}
}
 
[TestFixture]
[Category("class2")]
class Class21
{
[Test]
public void Test()
{}
}
 
[TestFixture]
[Category("class2")]
class Class22
{
[Test]
public void Test()
{}
}
 
[TestFixture]
class Class3
{
[Test]
[Category("function1")]
public void Test11()
{}
 
[Test]
[Category("function1")]
public void Test12()
{}
 
[Test]
[Category("function2")]
public void Test21()
{}
 
[Test]
[Category("function2")]
public void Test22()
{}
}
J#代碼:
/** @attribute TestFixture() */
/** @attribute Category("class1") */
public class Class11
{
/** @attribute Test() */
public void Test()
{}
}
 
/** @attribute TestFixture() */
/** @attribute Category("class1") */
public class Class12
{
/** @attribute Test() */
public void Test()
{}
}
 
/** @attribute TestFixture() */
/** @attribute Category("class2") */
public class Class21
{
/** @attribute Test() */
public void Test()
{}
}
 
/** @attribute TestFixture() */
/** @attribute Category("class2") */
public class Class22
{
/** @attribute Test() */
public void Test()
{}
}
 
/** @attribute TestFixture() */
public class Class3
{
/** @attribute Test() */
/** @attribute Category("function1") */
public void Test11()
{}
 
/** @attribute Test() */
/** @attribute Category("function1") */
public void Test12()
{}
 
/** @attribute Test() */
/** @attribute Category("function2") */
public void Test21()
{}
 
/** @attribute Test() */
/** @attribute Category("function2") */
public void Test22()
{}
}

上一頁1234567下一頁
軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 亚洲精品高清久久 | 天天看天天射天天视频 | 国产一区在线视频 | 韩国伊人| 男女后进式猛烈xx00动态图片 | a级大片免费看 | 欧美日本国产 | 亚洲精品图区 | 伊人性视频 | 在线观看福利影院 | 欧美video巨大粗暴多人 | 日日夜人人澡人人澡人人看免 | 毛片在线观看视频 | 国内精品在线观看视频 | 丁香六月 久久久 | 一级黄色大全 | 天天精品视频 | 涩涩污| 能直接看黄的网站 | 国产情侣草莓视频在线 | 欧美爆操| 123日本不卡在线观看 | 国产一区二区三区在线看 | 日本大蕉香蕉大视频在线观看 | h成人在线 | 日韩欧美色视频在线观看 | yy4138理论片在线大全 | 制服丝袜中文字幕在线 | 妞干网在线观看视频 | 欧美成视频 | 国产中文字幕久久 | 欧美成人亚洲高清在线观看 | 大又大又粗又爽又黄毛片女人 | 天天操天天干天搞天天射 | 成人人观看的免费毛片 | 日韩欧美第一页 | 天天爱天天舔 | 国产欧美日韩中文久久 | 在线你懂 | www.中文字幕在线观看 | 一级欧美视频 |