黄瓜前一步

发布于 2024-08-05 06:01:31 字数 79 浏览 3 评论 0原文

Cucumber 中是否有与 AfterStep 等效的 BeforeStep?

如果没有 - 有没有人找到解决方案/解决方法?

Is there a BeforeStep equivalent to AfterStep in Cucumber?

If not - has anyone found a solution / workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

扶醉桌前 2024-08-12 06:01:31

根据 GitHub 上 Cucumber Wiki 上有关 Hooks 的文档,答案是否定的。有 Before 但没有 BeforeStep。根据您想要实现的目标,Before 可能会满足您的需要。

According to the documentation on Hooks on the Cucumber Wiki on GitHub, the answer is no. There is Before but no BeforeStep. Depending on what you are trying to achieve, Before might do what you need.

七颜 2024-08-12 06:01:31

到目前为止,Before 在每个场景之前执行,而 AfterStep - 在场景中的每个步骤之后执行,要实现 BeforeStep,您只需将代码放在两个场景中即可挂钩:Before 和 AfterStep。

So far as Before is executed before each scenario and AfterStep - after each step in scenario, to achieve BeforeStep you can simply place you code in both hooks: Before and AfterStep.

少女净妖师 2024-08-12 06:01:31

我知道这是一个相当过时的问题,但是:

Before 可能会明确使用,例如在场景之前,但有时它是有意义的,因为它会污染场景描述。

我在 support/hooks.rb 中使用,例如

之前|场景|
//每个场景之前应该执行的事情
结束

如果必须在测试集中的每个场景之前重复某些操作,这可能会很有用

I know it is quite outdated question but:

Before might be used explicitly e.g before scenario but sometimes it is pointles due to fact that it pollute scenarios description.

I use in support/hooks.rb e.g

Before do |scenario|
//something which should be executed before each scenario
end

It might be usefull in case when some action action must be repeted before EVERY scenario in test set.

蓝咒 2024-08-12 06:01:31

我在 TestNG 中运行黄瓜。我想在处理特征文件时打印步骤定义名称。在 TestNG 下运行时似乎不会发生这种情况。如果我在方法上有 BeforeStep 注释,例如 beforeStep(StepDefinition sd)
(或类似的东西),我会记录步骤定义名称。这将非常有用。

有没有其他方法可以用 Java Cucumber 来做到这一点?

I am running cucumber within TestNG. I'd like to print the step definition names out as the feature file is processed. This doesn't appear to happen when running under TestNG. If I had a BeforesStep annotation on a method such as beforeStep(StepDefinition sd)
(or something like that), I'd log the step definition name. That would ve very useful.

Is there a different way to do this with Java Cucumber ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文