我发现TestCase
NUnit中的功能非常有用,可以快速指定测试参数,而无需为每个测试使用单独的方法.MSTest中有类似的东西吗?
[TestFixture]
public class StringFormatUtilsTest
{
[TestCase("tttt", "")]
[TestCase("", "")]
[TestCase("t3a4b5", "345")]
[TestCase("3&5*", "35")]
[TestCase("123", "123")]
public void StripNonNumeric(string before, string expected)
{
string actual = FormatUtils.StripNonNumeric(before);
Assert.AreEqual(expected, actual);
}
}
Run Code Online (Sandbox Code Playgroud)