本文介绍了在 IntelliJ 运行器中配置 @RunWith 以使用 CucumberWithSerenity.class 而不是 Cucumber.class的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a gradle + Serenity + RestAssured automated check suite setup that I usually run via gradle commands in shell sessions, but sometimes I need to run single Scenarios using IntelliJ.

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

When I run Scenarios on IntelliJ I usually get a lot of warnings like this one:

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 运行检查并修复警告.

I'd like to know where and how I can configure the Run/Debug Configuration in IntelliJ in order to run the checks with the CucumberWithSerenity.class and fix the warning.

我正在使用以下依赖项:

I'm using the following dependencies:

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

IntelliJ 版本 2018.1.5(社区版)

IntelliJ version 2018.1.5 (Community Edition)

推荐答案

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

Below are the steps from John Ferguson Smart' blog, author of Serenity-BDD (considering that you have installed Cucumber for Java plugin).

直接从 IntelliJ 使用 Serenity 功能文件运行 Cucumber:

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

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

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

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

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

P.S. Not all versions of Cucumber for Java plugin works correctly, especially when you have just updated IntelliJ IDEA to the latest version. I can confirm that next setup works correctly:

  • 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

这篇关于在 IntelliJ 运行器中配置 @RunWith 以使用 CucumberWithSerenity.class 而不是 Cucumber.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 20:48
查看更多