我有以下规格流场景:
Scenario: CasingMentions
When User mentions everyone with <casing> casing
Then user should be able to see the message they just sent
Examples:
| casing |
| lower |
| mixed |
| upper |
Run Code Online (Sandbox Code Playgroud)
步骤定义如下,该方法只接受一个字符串:
[When(@"User mentions everyone with (.*) casing")]
Run Code Online (Sandbox Code Playgroud)
这运行完全正常,但在 Visual Studio 上的测试运行程序中,它显示有一个空参数,因此上述场景将作为 3 个单独的测试出现在测试运行程序中,名称如下:
CasingMentions("lower",null)
CasingMentions("mixed",null)
CasingMentions("upper",null)
Run Code Online (Sandbox Code Playgroud)
在 feature.cs 文件中,如下所示:
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("CasingMentions")]
[NUnit.Framework.TestCaseAttribute("lower", null)]
[NUnit.Framework.TestCaseAttribute("mixed", null)]
[NUnit.Framework.TestCaseAttribute("upper", null)]
public virtual void CasingMentions(string casing, string[] exampleTags)
{
Run Code Online (Sandbox Code Playgroud)
我认为它与步骤定义无关,因为我可以将示例粘贴到不带参数的场景中,并且它仍然会执行此操作
这是显示我遇到的问题的视频:https://youtu.be/vC87WMFfJ4Y ?t=438
有什么办法可以摆脱空值吗?对于我使用示例表的每个场景都会发生这种情况,并且如果我使用场景或场景大纲似乎没有什么区别。如果这很重要的话,我正在使用 NUnit 作为我的测试运行程序。
我还尝试添加一个具有唯一值的额外列来尝试以这种方式命名测试用例,但它们只是作为括号中的另一个参数出现。