引用的相关依赖
<!--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());
}
原文:https://www.cnblogs.com/yxj808/p/14057286.html