分布式多个系统间的调用,写单测的时候需要设置挡板,调用其他系统的时候,不是真的调用,而是返回设置好的返回结果
需要的包(因为demo工程还有其他的依赖,一并拷贝了)
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.5.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.5.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4-rule-agent</artifactId>
<version>1.5.5</version>
<scope>test</scope>
</dependency>

本文档介绍在分布式系统中如何设置挡板进行单元测试,避免真实调用其他系统,而是返回预设结果。内容包括测试类的编写、挡板配置以及针对Controller URL的MockMVC测试方法。同时,提到了在JDK8下运行JDK7的挡板测试时遇到的问题及解决方案,即需要移除特定参数并添加-noverify来规避校验错误。
最低0.47元/天 解锁文章
8万+

被折叠的 条评论
为什么被折叠?



