【问题标题】:Scenario Steps(Given,When,Then) are not shown in IntelliJ console (Cucumber-Java with Junit)场景步骤(Given,When,Then)未显示在 IntelliJ 控制台中(Cucumber-Java with Junit)
【发布时间】:2020-06-04 17:09:34
【问题描述】:

当我在本地运行测试时,我在 IntelliJ 控制台中看不到 Feature-Scenario 步骤。通常你会看到每个场景的所有 Given,When,And,Then 步骤。

我确实在 IntelliJ 中安装了 Cucumber-Java 插件。和 IntelliJ Idea 版本 - IntelliJ Ultimate 2020.1 我在 pom 中的 cucumber、junit 和 java 版本:


<java.version>1.8</java.version>
    <junit.version>4.13</junit.version>
    <cucumber.version>5.6.0</cucumber.version>

RunnerTest


    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

感谢任何帮助。

谢谢, 尼迪

【问题讨论】:

    标签: intellij-idea junit


    【解决方案1】:

    看起来您正在使用 IDEA 来运行 Cucumber 测试,而不是 JUnit(RunCucumberTest1 类)。

    当您使用 IDEA 时,您的测试输出会自动分组到多个部分。如果您展开测试结果树(您可能需要切换一些过滤器),您可以单击一个步骤并查看其执行期间的输出。

    如果您想查看打印的步骤信息,您必须明确启用漂亮的打印机。您可以通过将 --plugin pretty 添加到运行配置菜单中的 CLI 参数来执行此操作。如果将其添加到模板中,则只需执行一次(请先删除所有旧的黄瓜运行配置)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-07
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多