从 SpecFlow 设置 Nunit TimeoutAttribute
我使用 SpecFlow 编写了几个长时间运行的端到端集成测试,但由于 Nunit 超时而失败。
将 [Timeout(x)] 属性添加到 TestFixture 可以解决问题,但当然每次功能更新时都会被覆盖。
如何以 SpecFlow 尊重的方式删除或延长超时?
I've written several long running end to end integration tests using SpecFlow, but they are failing due to Nunit timeouts.
Adding the [Timeout(x)] attribute to the TestFixture solves the issue, but of course gets overwritten everytime the feature is updated.
How can I remove or extend the timeout in a way that SpecFlow will respect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚开始了解 Specflow,但是您可以实现一个可以执行此操作的自定义标签吗?也许您可以将它们放在 BeforeScenario 或 BeforeFeature 挂钩中?
I am only getting to understand Specflow but could you implement a custom tag that could do this? Maybe you could place these at the BeforeScenario or BeforeFeature hooks?
我们谈论的跑步时间有多长? > 1分钟?
是否必须是完整的集成测试?
我正在读黄瓜书 - 它建议您尽可能多地作弊给定的步骤,以减少运行所需的时间。给出的步骤描述的是过去。
我的申请表有 5 个部分需要填写,只有在所有部分都完成后才能提交。我想测试提交应用程序时发生的一些功能,最初我的 GIVEN 语句通过 Selenium 驱动网页来完成表单的所有 5 个部分,以便我可以提交,我将其更改为单个 SQL 命令来设置应用程序所有待完成部分的状态。这减少了大约一分钟的运行时间。
我正在测试的是提交行为,填写部分测试是在其他地方完成的。
How long running are we talking about? > 1 minute?
Does it have to be a full integration test?
I was reading the cucumber book - it suggested that you cheat as much as possible for your GIVEN steps to reduce the time it takes for things to run. GIVEN steps are describing the past.
I have an application form that has 5 sections to complete and can only be submitted once all sections are completed. I wanted to test some functionality that occurs on submission of the application, originally my GIVEN statements were driving the webpage through Selenium to complete all 5 sections of the form so that I could submit, I changed this to a single SQL command to set the app status for all the sections to completed. This chopped about a minute off the runtime.
The thing I was testing was the submission behaviour, the filling out the sections tests are done elsewhere.
正如@DisscCoder 所说,
在功能文件中的场景中添加标签类别,并在钩子类中添加匹配的钩子....
SpecFlow 对字符串匹配的所有场景运行之前的场景代码挂钩代码。
小黄瓜:
As @DisscCoder says,
Add a tag category to the scenario in the feature file, and add a hook that matches in a hooks class....
SpecFlow runs the before scenario code hook code for all scenarios where the string matches.
Gherkin: