gpt4 book ai didi

java - 配置 @RunWith 以在 IntelliJ 运行器中使用 CucumberWithSerenity.class 而不是 Cucumber.class

转载 作者:行者123 更新时间:2023-12-01 19:46:53 25 4
gpt4 key购买 nike

我有一个 gradle + Serenity + RestAssured 自动检查套件设置,我通常通过 shell session 中的 gradle 命令运行,但有时我需要使用 IntelliJ 运行单个场景。

当我在 IntelliJ 上运行 Scenarios 时,我通常会收到很多像这样的警告:

8312 [main] WARN cucumber.runtime.SerenityBackend - It looks like you are 
running a feature using @RunWith(Cucumber.class)
instead of @RunWith(CucumberWithSerenity.class).
Are you sure this is what you meant to do?

我想知道在何处以及如何在 IntelliJ 中配置运行/调试配置,以便使用 CucumberWithSerenity.class 运行检查并修复警告。

我正在使用以下依赖项:

serenity-rest-assured:1.9.31
serenity-core:1.9.31
serenity-cucumber:1.9.12

IntelliJ版本2018.1.5(社区版)

最佳答案

以下是 Serenity-BDD 的作者 John Ferguson Smart 博客中的步骤(考虑到您已经安装了 Cucumber for Java 插件)。

Running Cucumber with Serenity feature files directly from IntelliJ :

IntelliJ provides excellent integrated support for Cucumber feature files. You can even run features simply by right-clicking on the feature file. But this won’t work when you are using Cucumber with Serenity, as Serenity needs to instrument the feature file before execution. Fortunately, this is easy to fix. Here’s how:

  • Click on the feature file you want to run
  • In the Run menu Select Run…
  • In the contextual menu, select the feature, then “Edit…”
  • You should now see the ‘Edit Configuration Settings’ window. Set the main class to ‘net.serenitybdd.cucumber.cli.Main’
  • Change the Glue field to the root package of your project (or of your step definitions)
  • Click Apply

Now you can run your feature directly by right-clicking on the feature file.

附注并非所有版本的 Cucumber for Java 插件都能正常工作,尤其是当您刚刚将 IntelliJ IDEA 更新到最新版本时。我可以确认下一个设置可以正常工作:

  • IntelliJ IDEA 2018.2.3(社区版);
  • Cucumber for Java 插件版本 182.3934;
  • net.serenity-bdd:serenity-core:2.0.6;
  • net.serenity-bdd:serenity-cucumber:1.9.18

关于java - 配置 @RunWith 以在 IntelliJ 运行器中使用 CucumberWithSerenity.class 而不是 Cucumber.class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52893323/

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