在特定功能之前/之后执行黄瓜步骤 [英] Execute Cucumber step before/after a specific feature

查看:129
本文介绍了在特定功能之前/之后执行黄瓜步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为每个特定功能文件指定特定的设置和删除步骤。我看到钩子允许代码在每个场景之前执行,并钩子在每个功能之前执行代码,但我想指定代码在所有场景运行一个特定功能之前和之后运行一次。

I want to specify certain setup and tear down steps for each specific feature file. I've seen hooks that allows code to execute before every scenario, and hooks to execute code before each feature, but I want to specify code to run once before and after all scenarios run for one specific feature.

这是否可能?

推荐答案

你使用cucumber-jvm ?我发现了一个符合你的要求的文章。

Do you use cucumber-jvm? I found an article that fits your requirement.

http://zsoltfabok.com/ blog / 2012/09 / cucumber-jvm-hooks /

基本上,不要使用JUnit @BeforeClass和@AfterClass,因为他们不知道黄瓜钩标签。你会希望Init和Teardown方法只在某些情况下运行吗?

Basically, do not use JUnit @BeforeClass and @AfterClass for this, as they are unaware of Cucumber Hook Tags. You would want Init and Teardown methods to run for certain scenarios only right?

这篇关于在特定功能之前/之后执行黄瓜步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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