MSTestã§ãã©ã¡ã¼ã¿åãã¹ã使ãããã£ãããChaining Assertion使ãã¨ãããï¼ã£ã¦ããã°ã«æ¸ããã®ãããªãã¨ãã3å¹´ååã«ãªããã§ãããæéãéããã®ã¯æ©ãããã§ãã
ããã¦ãæ°ãä»ãã¨MSTest v2ã§æ£å¼ã«ãã©ã¡ã¼ã¿åãã¹ãã使ããããã«ãªã£ã¦ãã¾ããã
使ãæ¹
Visual Studio 2017ã§ã¯MSTest v2ãæ¨æºã§ä½¿ç¨ãããããã§ãããã ãã.Net Framework 4.5以ä¸ãããã¯ã.Net Coreã§åä½ãã¹ãããã¸ã§ã¯ããä½æããå¿ è¦ãããã¾ãã
Visual Studio 2015以åã®å ´åã¯NuGetã§ã¤ã³ã¹ãã¼ã«ããã°ä½¿ããããã«ãªãã¨æãã¾ãï¼ç°å¢ããªãã®ã§è©¦ãã¦ãªãï¼
ã³ã¼ã
ãããªæããDataTestMethodAttributeã使ç¨ããå¿ è¦ãããã¾ãã
[TestClass] public class UnitTest1 { [DataTestMethod] [DataRow(1, 1, 2)] [DataRow(1, 2, 3)] [DataRow(2, 3, 4)] public void TestMethod1(int a, int b, int c) { Assert.AreEqual(c, a + b); } }
å®è¡çµæ
ãã¹ããå®è¡ããã¨ã以ä¸ã®ãããªçµæã表示ããã¾ãã
ã¾ã¨ã
å人çã«æã£åãæ©ãã®ã§ãMSTestã使ããã¨ãå¤ãã®ã§ãããæè¿ã¯xUnit.netã使ã£ã¦ãããã¸ã§ã¯ããããç®ã«ãã¾ãã
xUnit.netã使ã£ã¦ã¿ãããªããã¾ããèªåã®å ´åãã©ã£ã¡ã使ã£ã¦ãåãããªãã¨ããæ°ãããªãã§ããªãã§ããã
ããã¾ãã