从 JBehave 中的文本场景自动生成候选步骤方法存根

发布于 2024-12-24 18:11:28 字数 803 浏览 2 评论 0原文

我使用 Jbehave 作为我的 BDD 框架。我正在寻找一种从文本场景(如

Given there is a flight
And there is a customer
When the customer books the flight
Then the customer is shown on the manifest

Java)自动生成候选步骤方法存根的方法,如下所示:

<@> Given("there is a flight")
<a@> Pending
public void thereIsAFlight() {
}

<@> Given("there is a customer") // note 'Given', even though story line is 'And'
<@> Pending
public void thereIsACustomer() {
}

<@> When("the customer books the flight")
<@> Pending
public void theCustomerBooksTheFlight() {
}

<@> Then("the customer is shown on the flight manifest")
<@> Pending
public void thenTheCustomerIsShownOnTheFlightManifest() {
}

JBehave 是否将其作为隐式功能提供,或者人们使用某些 IDE 插件?我将非常感谢这里的任何帮助。

I am using Jbehave as my BDD framework. I am looking for a way to auto generate candidate step method stubs from the text scenarios like

Given there is a flight
And there is a customer
When the customer books the flight
Then the customer is shown on the manifest

to Java like this:

<@> Given("there is a flight")
<a@> Pending
public void thereIsAFlight() {
}

<@> Given("there is a customer") // note 'Given', even though story line is 'And'
<@> Pending
public void thereIsACustomer() {
}

<@> When("the customer books the flight")
<@> Pending
public void theCustomerBooksTheFlight() {
}

<@> Then("the customer is shown on the flight manifest")
<@> Pending
public void thenTheCustomerIsShownOnTheFlightManifest() {
}

Does JBehave provide it as an implicit functionality or people use some IDE plugin ? I'll highly appreciate any help here.

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

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

发布评论

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

评论(2

鹿! 2024-12-31 18:11:28

当您运行 JBehave 时,它​​会跟踪所有未找到匹配绑定代码的步骤,并转储相应的存根实现,与您编写的内容非常相似。
此输出可在控制台上使用,也可在 HTML 报告中使用(如果您打开了它们)。
复制它们并将它们放入您的步骤类中。

如果您要求 JBehave 自动将存根实现写入 .java 文件,那么我非常怀疑是否存在这样的功能 - 很难知道哪些步骤是 class & 的。要使用的文件。 (接下来是 SCM 集成问题等等。)

When you run JBehave it traces all steps that haven't found a matching binding code and dumps corresponding stub implementations as well, quite similar to what you wrote.
This output is available on the console but also in the HTML reports (should you have them turned on).
Copy them and place them into your steps class(es).

If you're asking to have JBehave automatically write the stub implementations into the .java files, then I highly doubt that there exists such a feature - it would be difficult to know which steps class & file to use. (Next to SCM integration problems and so forth.)

同展鸳鸯锦 2024-12-31 18:11:28

我使用 IntelliJBehave: https://github.com/kumaraman21/IntelliJBehave/wiki
它不会自动生成方法,但它确实为您提供了一些有用的功能,例如:语法突出显示、从步骤导航到方法、错误突出显示等等。

i use IntelliJBehave: https://github.com/kumaraman21/IntelliJBehave/wiki
it will not generate method automatically, but it does let you some useful abilities such as: syntax highlighting, navigation from steps to methods, error highlighting and more.

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