@Runwith(PowerMockRunner.class)
@PrepareForTest(Test.class)
public class A {
public static void main(String []args){
PowerMockito.mockStatic(Test.class);
when(Test.foo()).thenReturn(true);
B.foo();
}
}
The implementation of B is something like this
public class B{
public static void foo(){
boolean f = Test.foo();
}
}
I'm writing code to test B.foo()
which calls Test.foo()
I want to mock Test.foo()
to always return true
. But when I run this code it is producing an error when() requires an argument which has to be 'a method call on a mock
. I do not have permission to edit class B or class Test
. If I make the method in class A as Junit it is working fine. But I cannot running it as Junit as I'm running this on a lot of input. Is there is way to mock a method without the Junit?
Aucun commentaire:
Enregistrer un commentaire