Questions tagged «powermockito»

6
Mockito:模拟私有字段初始化
我如何模拟正在内联初始化的字段变量? class Test { private Person person = new Person(); ... public void testMethod() { person.someMethod(); ... } } 在这里,我想person.someMethod()在测试Test.testMethod()需要模拟person变量初始化的方法时进行模拟。有什么线索吗? 编辑:我不允许修改Person类。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.