mock模拟private static final now=system.currentmills;
First, at the beginning of the test class plus:
@prepareForTest({System.class})
Class A{
}
Then, in the method of adding:
powermockito.mockstatic (system.class);
powermockito.when (system.currentmills) .thenreturn (now);
system.currentmills;
To mock Simulations variable Class A {
private String a;
}
It can be:
String a = "test";
ReflectionUtils.set(new A(),'a',a);
To mock Simulations variable Class A {
private final String a;
}
It can be:
String a = "test";