maven集成cucumber,mvn test单元测试不运行
项目已集成cucumber,jacoco测试覆盖率100%,在application项目添加单元测试,覆盖率下降,发现单元测试覆盖的语句覆盖率没有统计到。经试验,发现是application项目下的单元测试没有运行,但domain项目的单元测试是正常运行的。
经过排除,是application项目的pom.xml文件的maven-surefire-plugin插件配置问题,原配置如下:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.22.2</version>
</dependency>
</dependencies>
</plugin>
这里是cucumber官网提示的配置,cucumber依赖junit4才能运行,但我单元测试使用了Junit5的注解,所以不能识别。
解决方法:只需要修改配置即可:
添加依赖:
<dependencies>
[...]
<dependency&