一、Mock静态块,静态变量,普通方法
1.准备工作
jar包版本最好保持一致
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
开始用的jmockit-1.41.jar,就执行测试案例的时候失败了
2.mock静态块和静态变量
需要调用的类:
public class SomeMethods {
public static String a = "我是静态变量";
static{
System.out.println("执行静态块...");
}
public static String sayHello(String name){
System.out.println("执行静态方法...");
return "Hello! " + name;
}
public String sayHi(String name){
System.out.println("执行普通方法...");
return "Hi! "</