【问题标题】:Maven not running cucumber tests with mvn clean verifyMaven 没有使用 mvn clean verify 运行黄瓜测试
【发布时间】:2021-07-23 20:10:36
【问题描述】:

我有一个单模块 Maven 应用程序,但mvn clean verify 只会在以下测试包结构中运行domain 下的测试,而不是acceptance 下的测试:

com->  x -> acceptance -> AcceptanceTests.java

com->  x -> domain -> <REST_OF_TESTS>

换句话说,mvn clean verify 只运行&lt;REST_OF_TESTS&gt;

这是我的AcceptanceTests.java,它完美地从 IntelliJ IDEA 运行:

package com.x.acceptance;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources", plugin = {"pretty"})
public class AcceptanceTests { }

我的最终目标是使用 mvn clean verify 在 Makefile 级别从终端运行所有测试,但 Cucumber 测试不会运行。你能帮忙吗?

谢谢。

【问题讨论】:

    标签: java maven cucumber bdd acceptance-testing


    【解决方案1】:

    当使用mvn verify Failsafe 时,测试名称应遵循以下约定:

    https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html 包含和排除测试包含

    默认情况下,Failsafe Plugin 会自动包含所有测试 具有以下通配符模式的类:

    "**/IT*.java" - includes all of its subdirectories and all Java filenames that start with "IT".
    "**/*IT.java" - includes all of its subdirectories and all Java filenames that end with "IT".
    "**/*ITCase.java" - includes all of its subdirectories and all Java filenames that end with "ITCase".
    

    如果测试类不遵循任何这些命名约定, 然后配置故障安全插件并指定您想要的测试 包括。

    当使用mvn test 时,使用 Surefire 并且测试名称应遵循以下约定:

    https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html 包含和排除测试包含

    默认情况下,Surefire 插件会自动包含所有测试 具有以下通配符模式的类:

    "**/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test".
    "**/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test".
    "**/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests".
    "**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".
    

    如果测试类不遵循任何这些命名约定, 然后配置 Surefire 插件并指定您想要的测试 包括。

    所以请仔细阅读您的班级名称​​非常。 如果这没有帮助,请尝试本教程并找出与您的项目的差异。

    https://cucumber.io/docs/guides/10-minute-tutorial/

    【讨论】:

      猜你喜欢
      • 2020-12-19
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      • 1970-01-01
      • 2019-12-06
      • 2021-04-23
      • 2015-02-10
      • 2018-10-08
      相关资源
      最近更新 更多