mes*_*ier 6 c# nunit visual-studio specflow
我有以下规格流场景:
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 作为我的测试运行程序。
我还尝试添加一个具有唯一值的额外列来尝试以这种方式命名测试用例,但它们只是作为括号中的另一个参数出现。
我发现没有办法摆脱最后一个“null”。最后一个参数用于与您的示例相关的标签。
MyTest("AA","40","11","mysite.com","ENG","+662154215","HotchocolateService","my@mysite.com","Insurance","2", null)
Run Code Online (Sandbox Code Playgroud)
如果你在你的例子上加上@import标签:
@important
Examples: | data | data2 |
Run Code Online (Sandbox Code Playgroud)
它将在 testcase 属性中进行解析:
MyTest("AA","40","11","mysite.com","ENG","+662154215","HotchocolateService","my@mysite.com","Insurance","2",["important"])
important 标签可用于确定某些测试用例的优先级,使其先于其他测试用例运行。
| 归档时间: |
|
| 查看次数: |
1334 次 |
| 最近记录: |