2017. 10. 27. 15:53

[준비하기]

 - VS 2017 템플릿

https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnitTemplatesforVisualStudio


- 다운로드 

  https://github.com/nunit/nunit/releases/3.8


- NUnit-Gui

테스트를 진행을 위한 GUI툴

 - https://github.com/NUnitSoftware/nunit-gui/releases


[프로젝트]

1. nuget에서 nunit 설치

    - NUnit3 

    - NUnit3TestAdapter


2. 프로젝트 생성

 Test메뉴에서 NUnit Test Project 선택


3. Attribute (https://github.com/nunit/docs/wiki/Attributes)

 -  [TestFixture]: 클래스에 지정하여 해당 클래스는 테스트를 위한 클래스라는 것을 지정하기 위해 사용

 - [SetUp]: 클래스 멤버나 기타 초기화가 필요한 경우 사용

 - [Test]: 메소드에 선언되며 단위별 테스트를 위한 사용

 - [ExpectedException(typeof(exception class))]: 예상되는 exception을 테스트할 경우 사용

 - [Ignore("메시지")]: 


3. Assert

 - 단위테스트의 주요 기능 결과를 확인 하기 위해 사용되는 클래스

 - 주요기능

  - AreEqual, AreNotEqual, AssertDoublesAreEqual, AreSame, AreNotSame

  - ByVal

  - True, False

  - IsTrue, IsFalse, IsEmpty, IsNull, IsNaN

  - Greater, GreaterOrEqual, , Less, LessOrEqual, Zero

  - Pass, Fail

  - Positive, Negative

  - Null, NotNull, Zero, NotZero

  - That

  - Throws


3. 테스트 실행

 - 메뉴 > 테스트 > 실행


[NUNIT Document]

https://github.com/nunit/docs/wiki/NUnit-Documentation

Posted by CoolDragon