如何重置PowerMockito.whenNew()行为?

时间:2011-10-03 16:13:40

标签: java mockito powermock

这就是我正在做的事情:

PowerMockito.mockStatic(Foo.class);
PowerMockito.whenNew(Foo.class).withNoArguments().thenReturn(null);
Foo foo1 = new Foo();
assert foo1 == null; // works fine
//...
// now I want PowerMockito to stop mocking the call
Foo foo2 = new Foo(); 
assert foo2 != null;

我找不到PowerMockito.reset()方法..什么是变通方法?

1 个答案:

答案 0 :(得分:1)

尝试

MockRepository.remove(Foo.class);