首页 > 其他 > 详细

用powermock单元测试

时间:2020-11-29 22:51:16      阅读:35      评论:0      收藏:0      [点我收藏+]
引用的相关依赖
<!--Junit-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.0.2</version>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>


@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)
@PowerMockIgnore({"javax.net.ssl.*", "javax.management.*", "javax.crypto.*"})
@SpringBootTest
public class BasePowerMock {
}

public class TestControllerPowerMock extends BasePowerMock {

@Resource
private
TestController testController;

/**
* 某接口
* @throws Exception
*/
@Test
public void test()throws Exception {
Testparam param= new Testparam();
param.setPhone("13330012265");
JsonBrandResult jsonBrandResult= testController.test(param);
Assert.assertEquals("S01",jsonBrandResult.getStatusCode());//验证返回值
System.out.println(jsonBrandResult.getData());
}
 

用powermock单元测试

原文:https://www.cnblogs.com/yxj808/p/14057286.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!