U E D R , A S I H C RSS

NUnit/C#예제

  1. C# . ()
  2. -> PopUp NUnit nunit.framework
  3. 트 하 Method Test, 한 클 TestFixture Attribute .
    1. SetUp TearDown Attribute .
  4. NUnit gui console dll exe Test 행한.

~cpp 
using System;
using System.IO;
using NUnit.Framework;
namespace NUnitByCShop
{	
	[TestFixture]
	public class AssertTester
	{
		[Test] public void ()
		{
			int actual = 3+2, expected = 5;
			Assertion.AssertEquals(expected,actual);			
			Assertion.Assert(actual == expected);
		}		
		[Test]
		public void Null()
		{
			int[] activeArray = {1,2,3};
			Assertion.AssertNotNull(activeArray);
			int[] nullArray = null;
			Assertion.AssertNull(nullArray);
		}
		[Test]
		public void 패하트()
		{
			Assertion.AssertEquals(5,3+4);
		}
	}
	[TestFixture]
	public class FileTester
	{		
		String fileName = "_________Test";	
		[SetUp] public  void 파()
		{		
			FileInfo fileInfo = new FileInfo(fileName);
			FileStream fileStream = fileInfo.Create();			
			fileStream.WriteByte(12);
			fileStream.Flush();
			fileStream.Close();
		}
		[TearDown] public void 파()
		{
			FileInfo fileInfo = new FileInfo(fileName);
			fileInfo.Delete();
		}
		[Test] public void 파()
		{                    
			FileInfo fileInfo = new FileInfo(fileName);
			Assertion.Assert(fileInfo.Exists);
		}
	}
}
NunitByC#ExampleGui.gif
NunitByC#ExampleConsole.gif

UnitTest 행하

xUnit 편하. 하 행할 .


  • (tool) .
  • External Tools .
  • Add .
  • Title ( :NUnit Test(Console) ) .
  • Command NUnit .(:C:\Program Files\NUnit 2.2\bin\nunit-console.exe)
  • Argument $(ProjectDir)\bin\debug\$(TargetName).exe . ( debug. release )
  • Use Output Window 택하 트 Output .

  • Tool .
  • Customize .
  • Keyboard .
  • Show Command Containing 택한. NUnit 행하 (External Command) . External Command8 . (VS2005 1 External Tools)
  • Press Shotcut Key(s) . (: Ctrl + ' )
  • .!!
----
NUnit
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:50
Processing time 0.0153 sec