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.0278 sec