New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
静态代码块 #301
Comments
支持直接Mock静态代码块内里的调用,具体一个实际的例子: 业务代码里使用静态代码块加载本地系统库,在运行单元测试的时候希望将它忽略。 public class JNIClass {
static {
System.loadLibrary("native-lib");
}
// 以下具引入的方法省略
public native String xxxx(... ...);
} 在测试时候时候Mock掉这个 public class JNIClassMock {
@MockInvoke(targetClass = System.class, targetMethod = "loadLibrary")
private void load(String libname) {
System.err.println("loadLibrary " + libname);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
比如:连接一个redis,采用是静态代码块的方式。测试的时候是否能屏蔽了?不然每次测试该类都要加载连接
The text was updated successfully, but these errors were encountered: