- C# 관련 로를 만든다. (는 래라브러리)
- 루 기를 로 -> PopUp 가 NUnit nunit.framework 가
- 고 는 Method 는 Test를, 래는 TestFixture Attribute를 붙다.
- 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); } } }
결과 |
![]() |
![]() |
단로 UnitTest 기 ¶
대로 기는 다른 xUnit 면 다. 만 몇 가 놓면 동로 다.
NUnit
- 명령 만들기
- 메뉴 구(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