Tag: powermockito

嘲弄保护方法

我想模拟一个inheritance的受保护方法。 我无法直接从java代码调用此方法,因为它inheritance自另一个包中的类。 我无法找到一种方法来指定这个方法来存入when(…) package a; public class A() { protected int m() {} } package b; public class B extends aA { // this class currently does not override m method from aA public asd() {} } // test package b; class BTest { @Test public void testClass() { B instance = PowerMockito.spy(new B()); PowerMockito.when(instance, […]