有没有一种方法可以针对预启动的Spring Boot服务器将Karate测试作为集成测试套件运行? [英] Is there a way to run Karate tests as an integration test suite against a pre-booted spring boot server?

查看:138
本文介绍了有没有一种方法可以针对预启动的Spring Boot服务器将Karate测试作为集成测试套件运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Maven构建的集成测试"阶段中,是否有什么好方法可以使空手道测试来测试Spring-Boot微服务?我的意思是:是否有一种反模式/变通办法行之有效?或者我是否很幸运,因为这是空手道发展的后遗症?

Is there any good way to get Karate tests to test a Spring-Boot microservice in the "integration-test" phase of a Maven build? What I mean is: is there an anti-pattern/workaround that works well OR am I out of luck because this was an afterthought of the Karate development?

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

Facts I have gathered so far:

  1. 它在这里说:"surefire插件未硬编码到空手道中" 是否可以运行在Maven的集成测试阶段进行空手道测试?

  1. It says here: "the surefire plugin is not hardcoded into Karate" Is there a way to run Karate test during maven's integration test phase?

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

Running Karate tests in context of maven-failsafe-plugin does not work at all. Easy to reproduce on my test project url below. Two problems foremost:

  1. 从maven-failsafe运行时,空手道将生成.txt和.html文件,但不生成.json黄瓜输出文件.
  2. 因此,从黄瓜报告插件(我需要)中无法获得HTML报告

  • 我创建了一个项目来证明这些事实: https://github.com /djangofan/karate-api-sample

    运行集成测试要求我在测试套件之前启动Spring Boot,然后在之后停止Spring Boot服务器. Maven SureFire不具备此功能,但maven failsafe插件却具有:maven build helper插件具有预集成测试钩子.仅受Maven surefire的限制,我很不走运.

    Running integration tests requires that I start Spring Boot before the test suite and then stop the spring boot server afterwards. Maven SureFire does not have this capability BUT the maven failsafe plugin does: the maven build helper plugin has a pre-integration-test hook for it. Limited only by Maven surefire, I am out of luck.

    我在karate/karate-demo项目中看到一个示例,该示例从代码启动spring boot服务器.当我尝试测试已建立的Web服务时,要实现此目标并不容易.这是我唯一的选择:将surefire与类过滤器结合使用并引导代码吗?

    I see an example in the karate/karate-demo project of starting the spring boot server from code. This is not easy to accomplish when I am trying to test a web service that is already established. Is this my only option: to use surefire with a class filter and code to bootstrap?

    没有给出好的答案,我将恢复使用cucumber-java + resteasy,我很确定它将与maven故障保护一起使用:

    Given no good answer, I will just revert to using cucumber-java + resteasy, which I am pretty sure will work with maven failsafe: https://maven.apache.org/surefire/maven-failsafe-plugin/examples/cucumber.html

    推荐答案

    首先,这不是Karate.js不确定来自何处:)

    First, this is not Karate.js not sure where that came from :)

    从maven-failsafe运行时,空手道将生成.txt和.html文件,但不生成.json黄瓜输出文件.

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

    对不起,无法复制.

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

    For failsafe, just use the naming conventions and it will work, e.g. **/IT*.java

    Maven SureFire不具有此功能,但maven故障安全插件具有:

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

    因此,请使用上述的故障保护.如果您无法执行此操作,请更改您的项目以演示该问题,我们承诺将对其进行修复.另请参阅以下说明: https://github.com/intuit /karate/wiki/如何提交问题

    So use failsafe as mentioned above. If you are not able to do that, please change your project to demonstrate the issue and we promise to fix it. Also refer these instructions: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

    如果没有好的答案,我将恢复为使用cumming-java + resteasy

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

    那当然是您的选择.至少在我(有偏见:)看来,您会丢失了空手道添加的所有JSON断言值,以及并行执行+报告汇总.我相信您会尽可能提供帮助,以便我们为所有需要此解决方案的人提供更好的体验-否则,嘿-不用担心:P

    That is of course your choice. At least in my (biased :) opinion you will miss all the JSON assertion value that Karate adds, and the parallel execution + aggregation of reports. I am sure you will help as far as possible so that we can make the experience better for all who need this solution - but else, hey - no worries :P

    这篇关于有没有一种方法可以针对预启动的Spring Boot服务器将Karate测试作为集成测试套件运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆