[英]How do you custom configure RESTeasy for use with Mockito?
I'm trying to figure out how to configure RESTeasy for use with Mockito. 我试图弄清楚如何配置RESTeasy与Mockito一起使用。 I had to create custom Serializers and Deserializers.
我必须创建自定义的序列化器和反序列化器。 I found this article that talked about creating custom serializers and deserializers and turning them into a module.
我发现这篇文章讨论了如何创建自定义序列化器和反序列化器并将它们转换为模块。
I also found this article and this article about configuring Jackson to use the new custom module that I wrote. 我也发现这个文章, 该文章有关配置杰克逊使用,我写了新的自定义模块。
The problem that I'm having is that I don't know how to test it. 我遇到的问题是我不知道如何测试。 One of the articles says
其中一篇文章说
The answer is to have Jackson(Jaxb)JsonProvider in the resteasy.providers section of resteasy-jaxrs.war/WEB-INF/web.xml
答案是在resteasy-jaxrs.war / WEB-INF / web.xml的resteasy.providers部分中具有Jackson(Jaxb)JsonProvider
I'm using Mockito to test everything. 我正在使用Mockito测试所有内容。 As far as I know, there isn't a resteasy-jaxrs.war file that is made.
据我所知,没有创建一个resteasy-jaxrs.war文件。 Is there anyway that I can fake this?
无论如何,我可以伪造吗?
I should probably also add that I'm using spring and I have an applicationContext.xml file that I use just for creating fake beans etc. for testing. 我可能还应该补充一点,我正在使用spring,并且有一个applicationContext.xml文件,该文件仅用于创建假豆等进行测试。
If you want unit tests REST application go with REST-assured. 如果要单元测试REST应用程序,请使用REST保证。 It is very simple and powerful library - you don't need to mock everything.
这是一个非常简单且功能强大的库-您无需模拟所有内容。 For other options see Ways to test RESTful services?
有关其他选项,请参见测试RESTful服务的方法? .
。
Remember that even if you manage to mock everything, such test might be hardly useful - you'll test your mocks, not a true application. 请记住,即使您设法模拟所有内容,这种测试也可能几乎没有用-您将测试模拟,而不是真正的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.