有没有办法 运行 空手道测试作为针对预启动 spring 启动服务器的集成测试套件?

Is there a way to run Karate tests as an integration test suite against a pre-booted spring boot server?

在 Maven 构建的 "integration-test" 阶段,是否有任何好的方法让空手道测试来测试 Spring-Boot 微服务?我的意思是:是否有一个 anti-pattern/workaround 效果很好,或者我运气不好,因为这是空手道开发的事后想法?

到目前为止我收集到的事实:

  1. 这里说:"the surefire plugin is not hardcoded into Karate"

  2. 运行 maven-failsafe-plugin 上下文中的空手道测试根本不起作用。很容易在下面的我的测试项目 url 上重现。两个最重要的问题:

    1. 当 运行 来自 maven-failsafe 时,空手道将生成 .txt 和 .html 文件但不会生成 .json Cucumber 输出文件。
    2. 因此,您无法从 cucumber-reporting 插件(我需要)获得 HTML 报告
  3. 我创建了一个项目来证明这些事实:https://github.com/djangofan/karate-api-sample

  4. 运行 集成测试要求我在测试套件之前启动 Spring 启动,然后停止 spring 启动服务器。 Maven SureFire 没有此功能,但 maven failsafe 插件有:maven build helper 插件有一个预集成测试挂钩。只受限于Maven surefire,我倒霉了

  5. 我在 karate/karate-demo 项目中看到一个从代码启动 spring 引导服务器的示例。当我尝试测试已经建立的 Web 服务时,这并不容易完成。这是我唯一的选择吗:将 surefire 与 class 过滤器一起使用并编码为 bootstrap?

  6. 如果没有好的答案,我将恢复使用 cucumber-java + resteasy,我很确定它可以与 Maven 故障保护一起使用:https://maven.apache.org/surefire/maven-failsafe-plugin/examples/cucumber.html

首先,这不是 Karate.js 不确定它来自哪里 :)

When running from maven-failsafe, Karate will generate .txt and .html files but does not generate .json Cucumber output files.

抱歉,无法复制。

对于故障保护,只需使用命名约定即可,例如**/IT*.java

Maven SureFire does not have this capability BUT the maven failsafe plugin does:

所以使用上面提到的故障保护。如果您无法做到这一点,请更改您的项目以证明该问题,我们承诺会修复它。另请参阅这些说明:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Given no good answer, I will just revert to using cucumber-java + resteasy

那当然是你的选择。至少在我(有偏见的 :) 看来你会 ,以及并行执行 + 报告聚合。我相信您会尽可能提供帮助,以便我们可以为所有需要此解决方案的人提供更好的体验 - 但是,嘿 - 不用担心 :P