【问题标题】:Configuring @RunWith to use CucumberWithSerenity.class instead of Cucumber.class in IntelliJ runners在 IntelliJ 运行器中配置 @RunWith 以使用 CucumberWithSerenity.class 而不是 Cucumber.class
【发布时间】:2018-10-19 13:26:39
【问题描述】:

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

当我在 IntelliJ 上运行场景时,我通常会收到很多类似这样的警告:

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(社区版)

【问题讨论】:

    标签: java intellij-idea cucumber serenity-bdd cucumber-serenity


    【解决方案1】:

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

    Running Cucumber with Serenity feature files directly from IntelliJ:

    IntelliJ 为 Cucumber 功能文件提供了出色的集成支持。您甚至可以通过右键单击功能文件来运行功能。但是,当您将 Cucumber 与 Serenity 一起使用时,这将不起作用,因为 Serenity 需要在执行之前检测功能文件。幸运的是,这很容易解决。方法如下:

    • 单击要运行的功能文件
    • 在运行菜单中选择运行...
    • 在上下文菜单中,选择功能,然后选择“编辑...”
    • 您现在应该看到“编辑配置设置”窗口。将主类设置为“net.serenitybdd.cucumber.cli.Main”
    • 将 Glue 字段更改为项目(或步骤定义)的根包
    • 点击应用

    现在您可以通过右键单击功能文件直接运行您的功能。

    附:并非所有版本的 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-19
      • 2022-01-13
      • 1970-01-01
      • 2013-11-19
      • 2015-03-14
      • 2019-12-15
      相关资源
      最近更新 更多