如何使用 Nunit 在运行时 SpecFlow 和 C# 期间忽略验收测试?
How to ignore acceptance tests during runtime SpecFlow and C# using Nunit?
我有一个 specflow API 服务测试场景,如下所示。周末 = 周六和周日。我们正在使用 Nunit 框架
Scenario Outline: Weekend test scenario for calculator scervice
Given today is weekend
And calculator with amounts <value1> , <value2> and <operator>
When calculator service is called
Then amount and operator field is editable
Examples:
| value1 | value2 | operator|
| 200 | 300 | plus |
我希望此测试在 运行 时间被忽略 - 如果我 运行 在工作日进行此测试。我该如何实现?
如果我正确理解了您的问题,我认为您可以在功能文件中使用标签。 NUnit 会将这些标记视为 Categories。
当需要运行测试时,你可以选择,你想要什么运行。
通过在要忽略的场景/功能中添加@Ignore 标签。
它将自动生成到生成文件中的相应属性
但是,这对你没有帮助。
您需要重写您的测试,以便它在运行时通过。
尝试使用存根和模拟来模拟当天
我有一个 specflow API 服务测试场景,如下所示。周末 = 周六和周日。我们正在使用 Nunit 框架
Scenario Outline: Weekend test scenario for calculator scervice
Given today is weekend
And calculator with amounts <value1> , <value2> and <operator>
When calculator service is called
Then amount and operator field is editable
Examples:
| value1 | value2 | operator|
| 200 | 300 | plus |
我希望此测试在 运行 时间被忽略 - 如果我 运行 在工作日进行此测试。我该如何实现?
如果我正确理解了您的问题,我认为您可以在功能文件中使用标签。 NUnit 会将这些标记视为 Categories。 当需要运行测试时,你可以选择,你想要什么运行。
通过在要忽略的场景/功能中添加@Ignore 标签。 它将自动生成到生成文件中的相应属性
但是,这对你没有帮助。 您需要重写您的测试,以便它在运行时通过。 尝试使用存根和模拟来模拟当天