是否有一种无需部署即可集成测试JAX-RS服务的机制(la MockMVC)? [英] Is there a mechanism for integration testing JAX-RS services without deploying (a la MockMVC)?

查看:87
本文介绍了是否有一种无需部署即可集成测试JAX-RS服务的机制(la MockMVC)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Mock MVC为Spring MVC REST服务成功构建了无需部署的集成测试框架.我正在竭力对JAX-RS服务进行同样的操作.

I have successfully built no-deployment-needed integration test frameworks for Spring MVC REST services using Mock MVC. I am struggling to do the same with JAX-RS services.

REST Assured看起来很有前途,但似乎需要部署.该测试套件可以启动CXF服务器,但是可以将其与servlet容器连接起来吗?

REST Assured looks promising, but it seems to require deployment. The test suite can start up a CXF server, but can it wire it up with a servlet container?

似乎Mock MVC提供的唯一值在其模拟servlet容器中.是否有其他技术可以提供此功能?

It seems that the unique value provided by Mock MVC is in its mock servlet container. Does any other technology provide this.

CXF文档的JAX-RS测试页面提供了一种将模拟 HttpServletRequest 注入CXF调用程序的模式.哪个让我在想...

The JAX-RS testing page of the CXF documentation provides a pattern for injecting a mock HttpServletRequest into a CXF invoker. Which got me thinking ...

Spring MVC的模拟servlet元素( MockHttpServletRequest 等)来自 spring-test 模块,独立于Mock MVC.我们能否将这些对象注入CXF调用程序中?还是这将是一个兔子洞?

Spring MVC's mock servlet elements (MockHttpServletRequest, etc.) come from the spring-test module, is independent of Mock MVC. Would we be able to inject these objects into a CXF invoker? Or will this be a rabbit hole?

有人解决这个问题吗?

.

推荐答案

Daniel-我是 Karate的开发人员并且我一直在尝试的是将Mockito和Spring模拟的组合用于HTTPServletRe ****以直接调用servlet,而不必引导应用服务器.

Daniel - I'm the developer of Karate and something I've been experimenting with is to use a combination of Mockito and the Spring mocks for the HTTPServletRe**** to call a servlet directly and avoid having to boot an app-server.

由于空手道拥有此 http客户端的可替换抽象,我正在考虑在不久的将来添加此选项.

Since Karate has this swappable abstraction of an http-client, I was thinking of adding this option in the near future.

只需共享,以帮助您提出建议或比较笔记.随时在GitHub上打开一个线程.

Just sharing in case it helps you with ideas, or if you want to compare notes. Feel free to open a thread on GitHub.

更新:我在此方面取得了很好的进展-请查看此线程作为工作示例.

Update: I made very good progress on this - please look at this thread for a working example.

这篇关于是否有一种无需部署即可集成测试JAX-RS服务的机制(la MockMVC)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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