分步执行后,黄瓜将停止执行 [英] Cucumber Stopping Execution after Time in Steps

查看:75
本文介绍了分步执行后,黄瓜将停止执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试之一一直等到Then步骤中发生事件.如果测试正常,则没有问题,但是如果测试失败(即未触发任何事件),则它会挂起.

One of my tests waits until an event happens in the Then step. If the test works fine there is no issue but if the test is failing (i.e. no event is triggered) then it just hangs.

如何在Cucumber中设置超时?

我知道JUnit具有一个超时参数,您可以在 @Test annotation Cucumber是否有类似内容?

I know JUnit has a timeout parameter you can use in the @Test annotation, is there something similar for Cucumber?

推荐答案

Cucumber遵循了JUnit模式,并在其步骤注释中提供了 timeout 参数.这需要一个较长的值,用于指定毫秒数,如果该秒数未完成执行,则该秒数将失败.

Cucumber has followed the JUnit pattern and offers a timeout parameter in its steps annotations. This takes a long value specifying the number of milliseconds after which the step is failed if it doesn't finish execution.

您可以按以下方式使用它:

You can use it as follows:

@Then(value = "^verify (\\d+) events sent$", timeout = 5000)

这也适用于其他步骤类型(例如GivenWhen).

This also works on the other step types (e.g. Given, When).

别忘了在步骤定义字符串之前添加value =.

Don't forget to add value = before the steps definition string.

这篇关于分步执行后,黄瓜将停止执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆