Java Maven没有';t运行单元测试-方法名称约定

Java Maven没有';t运行单元测试-方法名称约定,java,maven,junit5,maven-surefire-plugin,Java,Maven,Junit5,Maven Surefire Plugin,我想和大家分享我今天在多模块项目中尝试使用maven单元测试时的一个奇怪经历 当我直接从IDE(IntelliJ)运行测试时,一切工作都很完美。但是Maven只执行了一个测试类。我花了几个小时试图找出这种行为的原因。结果是,只执行名称以testxxx()开头的方法 我非常惊讶,因为我知道类级别的命名约定,但不知道方法级别的命名约定 你能理解发生了什么吗 这里是我正在使用的堆栈:Maven 3.6.0、JUnit 5、Maven surefire插件:3.0.0 编辑:此处是父级POM的依赖项部分

我想和大家分享我今天在多模块项目中尝试使用maven单元测试时的一个奇怪经历

当我直接从IDE(IntelliJ)运行测试时,一切工作都很完美。但是Maven只执行了一个测试类。我花了几个小时试图找出这种行为的原因。结果是,只执行名称以
testxxx()
开头的方法

我非常惊讶,因为我知道类级别的命名约定,但不知道方法级别的命名约定

你能理解发生了什么吗

这里是我正在使用的堆栈:Maven 3.6.0、JUnit 5、Maven surefire插件:3.0.0

编辑:此处是父级POM的依赖项部分:


${project.groupId}
迈尔普技术公司
${project.version}
${project.groupId}
髓鞘模型
${project.version}
${project.groupId}
迈尔普消费者
${project.version}
${project.groupId}
迈尔普业务
${project.version}
org.apache.logging.log4j
log4japi
${log4j.version}
org.apache.logging.log4j
log4j型芯
${log4j.version}
org.apache.logging.log4j
log4jcl
${log4j.version}
org.apache.logging.log4j
log4j-slf4j-impl
${log4j.version}
javax.validation
验证api
1.1.0.1最终版本
org.hibernate
休眠验证器
4.2.0.4最终版本
org.apache.commons
公共集合4
4.1
org.apache.commons
commons-lang3
3.5
org.springframework
弹簧芯
${spring.version}
编译
org.springframework
spring上下文
${spring.version}
编译
org.springframework
春豆
${spring.version}
编译
org.springframework
德克萨斯州春季
${spring.version}
编译
org.springframework
SpringJDBC
${spring.version}
编译
org.apache.commons
commons-dbcp2
2.1.1
org.postgresql
postgresql
9.4.1212
运行时
com.github.sbrannen
spring-test-junit5
1.4.0
测试
org.mockito
莫基托朱庇特酒店
3.0.0
测试
这里是一个类测试的示例,它被忽略,因为测试方法不是以testXXXX()开头的:

package com.dummy.myerp.model.bean.comptabilite;
导入org.junit.jupiter.api.Test;
导入java.util.ArrayList;
导入java.util.array;
导入java.util.List;
导入静态org.junit.jupiter.api.Assertions.assertEquals;
公共类TestDummy{
@试验
公共无效getByNumeroTest(){
整数numero1=1232;
整数numero2=92837;
整数numero3=空;
String libelleé1=“任命资本”;
字符串libellé2=null;
String libellé3=“产品例外”;
CompteComptable compteComptable1=新的CompteComptable(数字1,libellé1);
CompteComptable compteComptable2=新的CompteComptable(numero2,libellé2);
CompteComptable compteComptable3=新的CompteComptable(数字3,libellé3);
List list3elements=新建ArrayList(
asList(compteComptable1、compteComptable2、compteComptable3);
资产质量(compteComptable1,CompteComptable.getByNumero(列表3元素,数字1),“3元素,标准”);
assertEquals(compteComptable2,CompteComptable.getByNumero(list3elements,numero2),“3个元素,名称为空”);
assertEquals(null,CompteComptable.getByNumero(list3elements,numero3),“3个元素,帐户为null”);
assertEquals(null,CompteComptable.getByNumero(list3elements,5555),“3个元素,帐户不可用”);
}
}

包括
部分添加到surefire插件配置中。 例如:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M3</version>
                    <configuration>
                        <includes>*</includes>
                        <properties>
                            <configurationParameters>
                                junit.jupiter.extensions.autodetection.enabled = true
                            </configurationParameters>
                        </properties>
                    </configuration>
                </plugin>

org.apache.maven.plugins
maven surefire插件
3.0.0-M3
*
junit.jupiter.extensions.autodetection.enabled=true

听起来您的依赖项JUnit 3中有些地方没有完整的pom