部署要在测试中测试的微服务 [英] Deploying microservice to be tested within the test

查看:78
本文介绍了部署要在测试中测试的微服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这不可能在测试框架中通用完成,但

Maybe this is not possible to do generically in a test framework but

我希望能够在测试本身内 部署我正在测试的微服务.我看过Citrus,RestAssured和Karate,听了无数的演讲,读了无数的博客,但是我从未见过如何在第一阶段进行操作.似乎总是有这样一种假设,即微服务已预先部署.

I would like to be able to deploy the microservice I am testing within the test itself. I have looked at Citrus, RestAssured, and Karate and listened to countless talks and read countless blogs but I never see how to do this first stage. It always seems to be the case that there is an assumption that the microservice is pre-deployed.

推荐答案

老实说,这取决于微服务的部署方式和目标基础.我更喜欢将部署集成到Maven构建中,因为Maven提供了集成前和集成后测试阶段.

Honestly it depends on how your microservice is deployed and which infrastructure you are targeting on. I prefer to integrate the deployment into the Maven build as Maven provides pre- and post-integration-test phases.

如果可以使用Kubernetes或Docker,我建议将部署与fabric8 maven插件集成在一起( fabric8-maven-plugin docker-maven-plugin ).这样会自动在Maven构建中创建/启动/停止Docker容器部署.

In case you can use Kubernetes or Docker I would recommend integrating the deployment with fabric8 maven plugins (fabric8-maven-plugin, docker-maven-plugin). That would automatically create/start/stop the Docker container deployment within the Maven build.

如果您可以使用Spring boot,则官方的maven插件可以以相同的方式使用

In case you can use Spring boot the official maven plugin can do so in the same way.

另一种可能性是使用构建管道.例如,使用詹金斯(Jenkins)进行的连续构建将首先部署被测系统,然后在管道中执行测试.

Another possibility would be to use build pipelines. Where the continuous build with Jenkins for example would deploy the system under test first and then execute the tests in a pipeline.

我个人更喜欢始终将部署和测试任务分开.万一您真的想在测试中进行部署,因为Citrus框架可以在测试中启动/停止Docker容器和/或Kubernetes Pod. Citrus还可以与测试套件之前/之后的阶段进行集成,以完成这些部署任务.

I personally prefer to always separate deployment and testing tasks. In case you really want to do a deployment within your test Citrus as a framework is able to start/stop Docker containers and/or Kubernetes pods within the test. Citrus can also integrate with before/after test suite phases for these deployment tasks.

这篇关于部署要在测试中测试的微服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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