I have a final class
public final class A {
private static final Set<String> B = methodA();
private static Set<String> methodA() {
//does some processing and
//returns a set
}
public static boolean methodB() {
//does some processing and
//returns a boolean
}
}
The class under test is class B. This class is calling the static method of the final class A
public class B {
public boolean methodC() {
if(methodB()) {
C.methodD();
}
}
}
The class C is again a final class
public final class C {
public static void methodD() {
//does some processing
}
}
I am mocking this final class A like this
public class TestB {
public void testMethodC() {
PowerMockito.mock(A.class);
}
}
The case is failing inside the methodD of class C.
I am getting this error Mockito cannot mock this class: A.
You need some annotations:
My dependencies: