Tag: white box testing

如何使用Whitebox模拟私有方法(org.powermock.reflect)

我想模拟一个在另一个方法中调用的私有方法。 以下是我写的示例代码。 Java代码: package org.mockprivatemethods; public class AccountDeposit { // Instantiation of AccountDetails using some DI AccountDetails accountDetails; public long deposit(long accountNum, long amountDeposited){ long amount = 0; try{ amount = accountDetails.getAmount(accountNum); updateAccount(accountNum, amountDeposited); amount= amount + amountDeposited; } catch(Exception e){ // log exception } return amount; } private void updateAccount(long accountNum, long amountDeposited) throws […]