ran*_*jez 6 c# nunit unit-testing optional-parameters
我正在尝试运行一些测试用例,但我需要使其中一个参数可选.
我尝试了以下但是NUnit忽略了测试并打印了以下"忽略:提供的参数数量错误"
[TestCase(Result = "optional")]
[TestCase("set", Result = "set")]
public string MyTest(string optional = "optional")
{
return optional;
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用可选参数运行测试用例?
在这种情况下只需进行2次测试,nunit不支持可选的参数:
[TestCase("set", Result = "set")]
public string MyTest(string optional)
{
return optional;
}
[TestCase(Result = "optional")]
public string MyTest()
{
return MyTest("optional");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4975 次 |
| 最近记录: |