測試效果:示例中包含5個類,前4個類被分為class1和class2兩個組,后1個類中包含的四個方法被分為funtion1和function2兩個組。對于這種分組的測試,要想看出效果,在打開NUnit后,需要先在Categories選項卡中作出選擇,如下圖所示:
	
可以看到,所有的組默認都在上邊的Available Categories列表框中,選中的組則通過Add按鈕添加到下邊的Selected Categories列表框中,NUnit允許選中多個。測試完成后對于不想要的組,還可以通過Remove按鈕放回到上邊。選好后,選擇Tests選項卡,選中根節(jié)點,然后點擊Run按鈕,效果如下:
	
	 可以看到,只有與class1組對應的Class11和Class12這兩個類被測試了。
	 此外您可能也注意到了,Categories選項卡中還提供了一個Exclude these categories選項,選中該選項,回到Tests選項卡,選中根節(jié)點,然后點擊Run按鈕,效果如下:
	
	 此時與class1組對應的Class11和Class12這兩個類在測試中被忽略了。
	 
	    Explicit屬性,與Ignore屬性有些類似,也是用于對暫時不想運行的測試類或測試方法做忽略的。但與Ignore屬性相比還有兩點差別:一個是Explicit屬性不需要說明信息,一個是使用Explicit屬性做忽略的類或方法在NUnit中被選中后,將不再被忽略,而是進行測試。
	    示例:
	VB代碼:
	        <TestFixture()> _
	Public Class Test
	<Test(), Explicit()> _
	Public Sub TestMethod()
	End Sub
	End Class
	 
	<TestFixture(), Explicit()> _
	Public Class Test2
	<Test()> _
	Public Sub TestMethod()
	End Sub
	End Class
	C#代碼:
	        [TestFixture]
	public class Test
	{
	[Test, Explicit]
	public void TestMethod()
	{}
	}
	 
	[TestFixture, Explicit]
	public class Test2
	{
	[Test]
	public void TestMethod()
	{}
	}
	J#代碼:
	        /** @attribute TestFixture() */
	public class Test
	{
	/** @attribute Test(),Explicit() */
	public void TestMethod()
	{}
	}
	 
	/** @attribute TestFixture(),Explicit() */
	public class Test2
	{
	/** @attribute Test() */
	public void TestMethod()
	{}
	}
	    測試效果:類Test所忽略的是方法,若不在NUnit中選中該方法,測試后該方法前的圓點為黃色,即在測試中被忽略,若選中了則在測試后顯示為綠色或紅色,這與測試的結(jié)果有關;類Test2所忽略的是類,效果與Test類似。
	 
	    Platform屬性,平臺屬性,用來指定運行平臺,若測試類或測試方法所運行的平臺與指定的一致則執(zhí)行,否則忽略。此外,Platform屬性還提供了兩個參數(shù),Exclude和Include,前者用于指定將要忽略的平臺,后者指定將要運行的平臺。后者與默認指定的情況一致。
	    示例:
	VB代碼:
	<TestFixture()> _
	Public Class Test
	<Test(), Platform(Exclude:="Win98,Linux")> _
	Public Sub PlatformTest1()
	End Sub
	 
	<Test(), Platform(Include:="Win98,Linux")> _
	Public Sub PlatformTest2()
	End Sub
	End Class
	 
	<TestFixture(), Platform("Net-2.0")> _
	Public Class Test2
	<Test()> _
	Public Sub PlatformTest1()
	End Sub
	 
	<Test()> _
	Public Sub PlatformTest2()
	End Sub
	End Class
	C#代碼:
	[TestFixture]
	public class Test
	{
	[Test, Platform(Exclude="Win98,Linux")]
	public void PlatformTest1()
	{}
	 
	[Test, Platform(Include="Win98,Linux")]
	public void PlatformTest2()
	{}
	}
	 
	[TestFixture, Platform("Net-2.0")]
	public class Test2
	{
	[Test]
	public void PlatformTest1()
	{}
	 
	[Test]
	public void PlatformTest2()
	{}
	}
	J#代碼:
	/** @attribute TestFixture() */
	public class Test {
	/** @attribute Test() ,Platform(Exclude="Win98,Linux") */
	public void PlatformTest1()
	{}
	 
	/** @attribute Test() ,Platform(Include="Win98,Linux") */
	public void PlatformTest2()
	{}
	}
	 
	/** @attribute TestFixture(), Platform("Net-2.0") */
	public class Test2 {
	/** @attribute Test() */
	public void PlatformTest1()
	{}
	 
	/** @attribute Test() */
	public void PlatformTest2()
	{}
	}
	 測試效果:類Test所作用的是方法,測試后PlatformTest1前的圓點為綠色,PlatformTest2前的圓點為黃色,即在測試中被忽略,這是因為我為PlatformTest1指定的參數(shù)是Exclude,而PlatformTest2的參數(shù)是Include,因此在當前的.net2.0平臺下,不運行于Win98和Linux平臺的PlatformTest1能夠順利通過,而PlatformTest2則遭到忽略;類Test2所作用的是類,這里默認指定運行平臺為.net2.0,而當前運行平臺剛好是.net2.0,因此兩個方法都會運行通過。
	    此外,NUnit還給出了平臺的參考,摘錄如下:
	Win     Win32       Win32S      Win32Windows        Win32NT
	WinCE   Win95       Win98       WinMe               NT3
	NT4     NT5         Win2K       WinXP               Win2003Server
	Unix    Linux       Net         Net-1.0             Net-1.1
	Net-2.0 NetCF       SSCLI       Rotor               Mono
	  八、版本
	    《NUnit學習筆記》,2005年7月24日,NUnit版本2.2.0,IDE為Visual Studio.net 2003。
	    《NUnit學習筆記 VS.net 2005篇》,2006年1月28日,NUnit版本2.2.6,IDE為Visual Studio.net 2005。
	    《NUnit學習筆記 進階篇》,2006年1月29日,NUnit版本2.2.6,IDE為Visual Studio.net 2005和Delphi 2006。