Hook up in cucumber check for scenario failure in java(连接黄瓜检查java中的场景失败)
问题描述
当我在阅读如何为失败的黄瓜场景添加清理时,我在互联网上得到了这段代码.
While I was reading how to add a cleanup for a cucumber scenario on failure I got this piece of code in the internet.
After do |s|
if s.failed?
#If you are on an iOS Device
$driver.quit
sleep(time_for_driver_ready)
#else
reset
end
end
这是在红宝石中.我在java中工作,有什么方法可以在java中实现s.failed?
,因为在java中,after方法声明不包含场景变量.
This is in ruby. I am working in java and is there any way to implement s.failed?
in java, because in java the after method declaration does not include a scenario variable.
推荐答案
可以将Scenario作为参数传递给After hook,框架会将当前的scenario对象注入到方法中.
You can pass the Scenario as a parameter to the After hook, the framework will inject the current scenario object to the method.
@After
public void afterMethod(Scenario scenario) {
if(scenario.isFailed()) {
}
}
这篇关于连接黄瓜检查java中的场景失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:连接黄瓜检查java中的场景失败


- 未找到/usr/local/lib 中的库 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 获取数字的最后一位 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 转换 ldap 日期 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01