我有一个gradle + Serenity + RestAssured自动检查套件设置,通常在外壳程序会话中通过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为Cucumber功能文件提供了出色的集成支持。您甚至可以简单地通过右键单击特征文件来运行特征。但是,当您将Cucumber与Serenity一起使用时,这将无法正常工作,因为Serenity需要在执行之前先对功能文件进行检测。幸运的是,这很容易解决。就是这样:
单击要运行的功能文件
在运行菜单中,选择运行…。
在上下文菜单中,选择功能,然后选择“编辑...”
现在,您应该会看到“编辑配置设置”窗口。将主类设置为“ net.serenitybdd.cucumber.cli.Main”
将胶水字段更改为您的项目(或您的步骤定义)的根包
点击应用
现在,您可以通过右键单击功能文件直接运行功能。
附言并非所有版本的Cucumber for Java插件都能正常工作,尤其是在您刚刚将IntelliJ IDEA更新到最新版本时。我可以确认下一个设置可以正常工作:
IntelliJ IDEA 2018.2.3(社区版本);
用于Java插件版本182.3934的黄瓜;
net.serenity-bdd:serenity-core:2.0.6;
net.serenity-bdd:serenity-cucumber:1.9.18