java - 在 IntelliJ 运行器中配置 @RunWith 以使用 CucumberWithSerenity.class 而不是 Cucumber.class
问题描述
我有一个 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(社区版)
解决方案
以下是 Serenity-BDD 的作者 John Ferguson Smart 的博客中的步骤(考虑到您已经安装了Cucumber for Java插件)。
直接从 IntelliJ 使用 Serenity 功能文件运行 Cucumber:
IntelliJ 为 Cucumber 功能文件提供了出色的集成支持。您甚至可以通过右键单击功能文件来运行功能。但是,当您将 Cucumber 与 Serenity 一起使用时,这将不起作用,因为 Serenity 需要在执行之前检测功能文件。幸运的是,这很容易解决。就是这样:
- 单击要运行的功能文件
- 在运行菜单中选择运行...</li>
- 在上下文菜单中,选择功能,然后选择“编辑...”</li>
- 您现在应该看到“编辑配置设置”窗口。将主类设置为 'net.serenitybdd.cucumber.cli.Main'</li>
- 将 Glue 字段更改为项目(或步骤定义)的根包
- 单击应用
现在您可以通过右键单击功能文件直接运行您的功能。
PS 并非所有版本的 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:宁静黄瓜:1.9.18
推荐阅读
- c++ - 如何声明 constexpr c-string 成员?
- sql - Oracle INSERT 语句,以“b”开头的字符串文字
- chef-infra - 如何根据 bash 命令的输出包含厨师食谱?
- authentication - Auth0 调用 API
- c# - 在 ScrollViewer 中缩放 InkCanvas 会剪切画布 - UWP
- compiler-errors - OmniOS 上的 Freetype2 64 位
- python-3.x - 如何解除阻塞已删除命名管道上的线程阻塞?
- typescript - 在 Webpack Visual Studio 2017 .NET Core 2.2 捆绑的 Chrome 中调试 Typescript
- ios - 测试给定的 iPhone 是否支持展开模式下的拆分视图
- c# - C# 控制台应用程序 - 运行节点 JS 脚本文件