gpt4 book ai didi

javascript - 如何按照 Ruby Cucumber 文档中的描述在 Cucumber.js 中组合步骤?

转载 作者:行者123 更新时间:2023-11-30 14:14:21 25 4
gpt4 key购买 nike

此处:https://relishapp.com/cucumber/cucumber/docs/defining-steps/nested-steps#use-#steps-to-call-several-steps-at-once

我没有代码示例来说明我的意思,只是说我想在一个步骤中合并并执行多个步骤(想想:代码重用)。我不知道如何使用 Cucumber.js 完成此操作;文档有点粗略。 :-\

最佳答案

简而言之,您不能,而且很可能永远无法直接在 cucumber-js 中执行此操作。

Matt Wynne 和 Aslak Hellesoy 似乎对曾经在 cucumber-ruby 中实现这个概念感到遗憾,并建议改用辅助方法。

aslakhellesoy commented on Oct 16, 2012

Calling steps from stepdefs is one of those features I wish I never added to Cucumber(-Ruby), because it provides so much rope for people to hang themselves with. It came to be because Ruby stepdefs use anonymous closures that you can't call from elsewhere (unless you go through hoops).

With JavaScript it's a different situation; Step Definitions use first class functions!


mattwynne commented on Aug 27, 2014

I suggest you use helper methods on your World to achieve this kind of reuse. We implemented this feature (we call it "nested steps") in the Ruby Cucumber, and it's been hard to maintain, and led to some very complex dependencies in people's test code.

显然 Julien Biezemans 同意

jbpros commented on Aug 13, 2014

Thanks @cono for the PR. However, as has been discussed before this will not be implemented in Cucumber.js.

关于这个主题的更多信息:

关于javascript - 如何按照 Ruby Cucumber 文档中的描述在 Cucumber.js 中组合步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53843747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com