intellij-idea - 场景步骤(Given,When,Then)未显示在 IntelliJ 控制台中(Cucumber-Java with Junit)
问题描述
当我在本地运行测试时,我在 IntelliJ 控制台中看不到 Feature-Scenario 步骤。通常你会看到每个场景的所有 Given,When,And,Then 步骤。
而且我确实在 IntelliJ 中安装了 Cucumber-Java 插件。还有 IntelliJ Idea 版本 - IntelliJ Ultimate 2020.1 我在 pom 中的黄瓜、junit 和 java 版本:
<java.version>1.8</java.version>
<junit.version>4.13</junit.version>
<cucumber.version>5.6.0</cucumber.version>
跑步者测试
package io.cucumber.hellocucumber;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty"})
public class RunCucumberTest1 {
}
特征文件
Feature: Is it Friday yet?
Everybody wants to know when it's Friday
Scenario: Sunday isn't Friday
Given today is Sunday
When I ask whether it's Friday yet
Then I should be told "No"
Scenario: Friday is Friday
Given today is Friday
When I ask whether it's Friday yet
Then I should be told "TGIF"
测试结果/输出
sampling ...
include patterns:
io\.cucumber\.core\.cli\..*
exclude patterns:
Jun 04, 2020 11:31:23 AM io.cucumber.core.cli.Main run
WARNING: By default Cucumber is running in --non-strict mode.
This default will change to --strict and --non-strict will be removed.
You can use --strict to suppress this warning
1 Scenarios (1 passed)
3 Steps (3 passed)
0m0.583s
Class transformation time: 0.0138887s for 1552 classes or 8.948904639175257E-6s per class
Process finished with exit code 0
任何帮助表示赞赏。
谢谢,尼迪
解决方案
看起来您正在使用 IDEA 来运行 Cucumber 测试,而不是 JUnit(RunCucumberTest1 类)。
当您使用 IDEA 时,测试的输出会自动分组到各个部分。如果您展开测试结果树(您可能需要切换一些过滤器),您可以单击一个步骤并查看其执行期间的输出。
如果您想查看打印的步骤信息,您必须明确启用漂亮的打印机。您可以通过--plugin pretty
在运行配置菜单中添加 CLI 参数来完成此操作。如果将其添加到模板中,则只需执行一次(首先删除所有旧的黄瓜运行配置)。
推荐阅读
- c++ - 为什么 C++ 引用会耗尽结构中的内存?
- c++ - 如何将 char 类型变量附加到字符串?
- rxjs - 带间隔的 concatMap 未按预期工作
- c++ - TS Concepts 类型名约束
- android - Google Play 订阅始终“待付款”
- javascript - 使用带有换行符的php字符串作为javascript变量
- angular - ngClass 正在删除加载时的选择选项
- angular - angular ionic - jwt 令牌标头发布错误
- css - 我的网站在 PC 和移动设备上的导航栏显示出现问题
- python - Python 3 BeautifulSoup 从跨度类中剥离特定值?