public class CacheAdder{
private static final int HARD_CACHE;
static {
HARD_CACHE = 22;
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
e.printStackTrace();
}
public int divide(int number, int divider) {
return (int) HARD_CACHE+number/divider;
}
}
When I mock and run tests through this example class, mockito skips the static part which makes sense because I mock the value of HARD_CACHE but at the same time I want 100% coverage through the code. Should static fields be tested without mocks? Or is there a way to test static fields/methods/variables using mocks?