spring-boot - Jenkins 无法使用 Maven Surefire、Spring Boot 和 JUnit5 执行 Cucumber 测试
问题描述
我正在使用Cucumber Runner/Spring Boot/JUnit5 spring-boot-starter-parent:2.2.6.RELEASE
/ cucumber-java8:5.6.0
Maven Surefire 执行 e2e 测试。我在 Linux VM 上安装了最新的 Jenkins Community LTS v2.222.1 并将我的笔记本电脑连接为从属设备。
当我使用 IDE / 命令提示符在我的笔记本电脑上执行测试时,它工作正常(使用mvn clean test
)。但是,当从 Jenkins 触发时,相同的测试不会运行。这有点令人困惑,因为我使用的是相同的配置/工具。
詹金斯控制台 O/P:
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to C:\Jenkins\workspace\Sanity\core\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ project-core ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
Apr 07, 2020 1:08:45 PM net.masterthought.cucumber.ReportParser parseForFeature
INFO: File {0} does not contain features
Apr 07, 2020 1:08:45 PM net.masterthought.cucumber.ReportParser parseJsonFiles
INFO: File 'C:\Users\User\AppData\Local\Temp\2\cucumber5203280546924184867.json' contains 0 features
Apr 07, 2020 1:08:45 PM net.masterthought.cucumber.ReportBuilder generateErrorPage
INFO: Unexpected error
net.masterthought.cucumber.ValidationException: Passed files have no features!
...
IDE 控制台 O/P:
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to C:\Code\project\core\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ project-core ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.x.y.z.CucumberTests
2020-04-07 13:22:52.330 INFO --- [ main] .b.t.c.SpringBootTestContextBootstrapper : Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.x.y.z.stepdefs.LogVerificationSteps], using SpringBootContextLoader
...
CucumberTests.java:
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"pretty", "de.monochromata.cucumber.report.PrettyReports:target"},
features = "src/test/resources/features")
public class CucumberTests {
}
这是多模块 maven 项目,功能如下:
root
\__core
\__src/test/resources/features/*
所以基本上在詹金斯功能/测试中根本没有运行 - 为什么会发生,任何想法的人?
解决方案
推荐阅读
- postgresql - postgres窗口函数三倍查询时间
- c++ - 使用 SDL2 时,'' 的左侧必须有类/结构/联合
- python - python中的Tkinter - 未找到
- python - 如何使 dockerized Flask 应用程序将输出写入文件?
- javascript - 如何从 NodeJS 连接到 PostgreSQL
- laravel - Laravel - 从控制器中的多个字段计算最小值
- html - 在 mvc razor 上的 href 中解析错误“/@”
- php - 如果用户的时区使用 PHP 更改,如何处理存储在数据库中的用户数据
- docker - Kibana Docker“这可能需要几分钟”但从不启动
- arrays - 将数组存储在数据库 Wordpress 中