【问题标题】:Cannot see cucumber snippets on logs在日志上看不到黄瓜片段
【发布时间】:2019-12-15 19:27:53
【问题描述】:

我刚刚启动了一个 2.1.6 版的 sping-boot 项目(使用启动器:spring-boot-starter-web、spring-boot-starter-test)

我正在尝试在 4.7.1 版中使用 cucumber for java,并带有以下 maven 依赖项:cucumber-spring、cucumber-junit、cucumber-java8。

当我启动验收测试时,我会在日志中看到未定义步骤。但是没有出现sn-ps

AllAcceptanceTests

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty", "html:FeaturesReport"},
        features = {"src/test/resources/features"},
        snippets = CucumberOptions.SnippetType.UNDERSCORE)
public class AllAcceptanceTests {
}

我的场景

  Scenario: Creation from initialisation
    Given name "Jean"
    Given gender "Male"
    Given picture "picture.png"
    Given account identifier 1
    When try to create the profile with these parameters
    Then the profile id = 1 , name = "Jean" , gender = "Male" and picture = "picture.png" is saved

Junit 日志

  Scenario: Creation from initialisation                                                            # src/test/resources/features/create-profile.feature:9
    Given name "Jean"                                                                                       # ProfileSteps.java:23
    Given gender "Male"                                                                                     # ProfileSteps.java:27
    Given picture "picture.png"                                                                             # ProfileSteps.java:31
    Given account identifier 1                                                                              # null
    When try to create the profile with these parameters                                                    # ProfileSteps.java:37
    Then the profile id = 1 , name = "Jean" , gender = "Male" and picture = "picture.png" is saved # ProfileSteps.java:46

io.cucumber.junit.UndefinedThrowable: The step "existing account in nisfee-account :" is undefined

我正在使用所有 spring-boot 默认配置。我是不是因为在我的日志中有这样的东西而忘记了什么:

You can implement missing steps with the snippets below:

@Given("^today is Sunday$")
public void today_is_Sunday() {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

【问题讨论】:

    标签: java spring spring-boot junit cucumber


    【解决方案1】:

    如果您通过 JUnit 而不是 CLI 或 IDEA 运行,则必须显式添加 summary 插件。

    @CucumberOptions(plugin = {"summary", "pretty", "html:FeaturesReport"},
    

    【讨论】:

    • 非常感谢。是的,我正在研究 intellij 和 intellij 的步骤生成器忽略数据表,这就是为什么我需要这个功能来快速工作。以前的版本我们不必指定这个插件,它对我来说是全新的^^
    猜你喜欢
    • 2017-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多