ä»é¢¨ã®NUnitã¤ã³ã¹ãã¼ã«
è·å ´ã§ä½åº¦ãæé ãæ¸ãããããã¨ã«ããå æ¸å«æ°ããããã®ã§ï¼ä»åº¦ããæãã¤ããããããã«ã¾ã¨ãã¦ãããã¨ã«ãã¾ãï¼
ä»é¢¨ãã¨è¨ãããã¨ä»æ´é¢¨ãªã®ããããã¾ããããï¼
å°ãªãã¨ãå¼ç¤¾ã§ã¯ã¤ã³ã¹ãã¼ã©ãè½ã¨ãã¦ãã¦ã¤ã³ã¹ãã¼ã«ãããããnugetããã¤ã³ã¹ãã¼ã«ããã»ããï¼å¨ãçã®ãªããã¼ãã«ã¯ä½ãããã§ãï¼
nugetãã¾ããã
Visual Studioãéãï¼ã¡ãã¥ã¼ãã [ãã¼ã«] - [ã©ã¤ãã©ãª ããã±ã¼ã¸ ããã¼ã¸ã£ã¼] - [ããã±ã¼ã¸ ããã¼ã¸ã£ã¼ ã³ã³ã½ã¼ã«]ãéãã¾ãï¼
ããã±ã¼ã¸ ããã¼ã¸ã£ã¼ ã³ã³ã½ã¼ã«ã®ä¸é¨å³å´ã«ãã [æ¢å®ã®ããã¸ã§ã¯ã] ããã¹ããããï¼ãããã¯ãã¹ããæ¸ãäºå®ã®ï¼ããã¸ã§ã¯ãã«è¨å®ãã¾ãï¼
ããã±ã¼ã¸ ããã¼ã¸ã£ã¼ ã³ã³ã½ã¼ã«ã«
Install-Package NUnit
ã¨å ¥åã㦠[Enter]ï¼
NUnitãã¤ã³ã¹ãã¼ã«ããï¼ããã¸ã§ã¯ãã®åç §è¨å®ã¾ã§è¡ããã¾ãï¼
次ã«å ã»ã©NUnitãã¤ã³ã¹ãã¼ã«ããããã¸ã§ã¯ãã®ä¸ã®ãã¹ãã³ã¼ããéãã¦ï¼ä»ã®usingãã£ã¬ã¯ãã£ãã®ä¸ãããã«
using NUnit.framework;
ã¨æ¸ãã¾ãï¼
å ãã¦ï¼ããæãã«ãã¹ããæ¸ãã¦ããã¾ãï¼ãã¹ãã®æ¸ãæ¹ã¯ NUnitã®å ¨è² ï½ åºæ¬ãããææ°ãã¼ã¸ã§ã³ã®æ°æ©è½ã¾ã§ ï¼1/8ï¼ï¼CodeZine ããããåèã«ã©ããï¼ï¼
Test Adapterãã¾ããã
Visual Studioã®ã¡ãã¥ã¼ã§ [ãã¼ã«] - [æ¡å¼µæ©è½ã¨æ´æ°ããã°ã©ã ] ãéãã¾ã*1ï¼
å·¦ã®ã¡ãã¥ã¼ãã [ãªã³ã©ã¤ã³] - [Visual Studio ã®ã£ã©ãªã¼] ãé¸æãã¾ãï¼
å³ä¸ã® [Visual Studio ã®ã£ã©ãªã¼ã®æ¤ç´¢(Ctrl+E] ã«ãNUnit Test Adapterãã¨å ¥åãã¾ãï¼
ãNUnit Test Adapterãã® [ãã¦ã³ãã¼ã] ãæ¼ãã¾ãï¼
ããã¦ã³ãã¼ãã¨ã¤ã³ã¹ãã¼ã«ãç»é¢ã表示ãããã®ã§é²ãã¾ãï¼
ã¤ã³ã¹ãã¼ã«ãçµãã£ããVisual Studioã®åèµ·åãæ±ããããã®ã§å¤§äººããåèµ·åãã¾ãï¼
ãã¹ãã¨ã¯ã¹ããã¼ã©ã¼ã表示ããã¦ããªããã° [ãã¹ã] - [ã¦ã£ã³ãã¦] - [ãã¹ãã¨ã¯ã¹ããã¼ã©ã¼] ãã表示ãã¾ãï¼
Testãã¾ããã
ããã¾ã ãã¹ããæ¸ãã¦ãªããã°ï¼ã¨ããããé©å½ã«æ¸ãã¦ãã«ããã¾ãï¼
[ãã¹ãã¨ã¯ã¹ããã¼ã©ã¼] ã«ãã¹ãã表示ããã¾ãï¼
[ãã¹ãã¨ã¯ã¹ããã¼ã©ã¼] ã®ä¸é¨ã«ãã [ãã¹ã¦å®è¡] çã®å®è¡ãã¿ã³ãæ¼ãã¨ãã¹ããèµ°ãã¾ãï¼
ããã§ãç§ã¯GUIã好ã
Visual Studioã®ãã¹ãã¨ã¯ã¹ããã¼ã©ã¼ãå«ãã£ã¦ããæ¹ãããã£ããããããªã®ã§ï¼
NUnitã®GUIã«ã¯.NET Framework3.5ãå¿ è¦ãªã®ã§è¦³å¿µãã¦äºåã«ã¤ã³ã¹ãã¼ã«ãã¦ããã¦ãã ããï¼ãã¤ã¯ãã½ããå ¬å¼ãã¦ã³ãã¼ã ã»ã³ã¿ã¼ãã Microsoft .NET Framework 3.5 ããã¦ã³ãã¼ãï¼ï¼
Visual Studioã® [ããã±ã¼ã¸ ããã¼ã¸ã£ã¼ ã³ã³ã½ã¼ã«] ãå度éãã¾ãï¼
Install-Package NUnit.Runners
ãå ¥åã㦠[Enter]ï¼
ã¤ã³ã¹ãã¼ã«ãçµãã£ããã½ãªã¥ã¼ã·ã§ã³ã®ãã£ã¬ã¯ããªãéã packages\NUnit.Runners.2.6.3\tools\nunit.exe
ï¼32bitãªãnunit-x86.exeï¼ãå®è¡ãã¾ãï¼
ã¨ããã§ï¼.NET Framework3.5ãã¤ã³ã¹ãã¼ã«ããã¦ããªãã¨ï¼ãã®ã¿ã¤ãã³ã°ã§â¦
ãããªãã¨ã«ãªãã¾ãï¼ã¾ããã®ç¶æ ããã¤ã³ã¹ãã¼ã«ããã°ãããã§ããï¼
ãã¦ï¼æ°ãåãç´ãã¦GUIã® [Tools] - [Settings] ã§è¨å®ç»é¢ãéãã¾ãï¼
å·¦ã®ããªã¼ãã [IDE Support] - [Visual Studio] ãé¸æãã¾ãï¼
[Enable Visual Studio Support] ã«ãã§ãã¯ãå ¥ãã¾ãï¼ããã§ããã¸ã§ã¯ããã¡ã¤ã«ãèªã¿è¾¼ããããã«ãªãã¾ãï¼ï¼
[OK] ãæ¼ãã¦è¨å®ç»é¢ãéãã¾ãï¼
[File] - [Open Project...] ãããã¹ããããããã¸ã§ã¯ããã¡ã¤ã«ï¼.csprojãã¡ã¤ã«ï¼ãé¸æãã¾ãï¼
ãã¹ãããã¼ããããã®ã§ [Run] ãæ¼ãã°ãã¹ããå®è¡ããã¾ãï¼
Settingsã«ã¯ãã£ã¨ä¾¿å©ãªé ç®ãããã®ã§æéã®ããã¨ãã«ã§ãè¦ã¦ã¿ãã¨å¹¸ãã«ãªããããããã¾ããï¼
ããã§ãç§ã¯ã¤ã³ã¹ãã¼ã©ã好ã
ãªãã§ãããã§ãVisual Studioã«ãã£ã¤ãã®ãã¤ã¤ã ã¨ããæ¹ãããã£ããããããªã®ã§ï¼
NUnitã®ã¤ã³ã¹ãã¼ã©ã使ãå ´åã«ã.NET Framework3.5ãå¿ è¦ãªã®ã§è¦³å¿µãã¦äºåã«ã¤ã³ã¹ãã¼ã«ãã¦ããã¦ãã ããï¼
NUnit - Download ããææ°å®å®æ¿ã®msiããã¦ã³ãã¼ããå®è¡ãã¾ãï¼
ã¤ã³ã¹ãã¼ã«ã¯åºæ¬çã«ã¯ä¸æ¬éã§ããï¼å¯ä¸éä¸ã§ãSetup Typeããèããã¾ãï¼
[Typical] ã§åé¡ãªãã¯ãã§ãï¼
ã¾ã
便å©ã§ãããï¼nugetï¼
*1:æ¡å¼µæ©è½ã¯Visual Studioã®Expressã§ã¯ä½¿ããªãã®ã§NUnitã®GUI使ããã¨ã«ãªãã¾ãã®ã§ã注æãï¼