【发布时间】:2015-05-26 10:04:04
【问题描述】:
我需要测试一个要求用户输入并向玩家收取输入金额的方法。待测方法:
public void askForBetSize() {
System.out.println("\nYour stack: " + player.getBalance());
System.out.print("Place your bet: ");
bet = Integer.parseInt(keyboard.nextLine()); // = this needs to be simulated
player.charge(bet);
}
当前的单元测试是:
@Test
public void bettingChargesPlayerRight() {
round.setCards();
round.askForBetSize(); // here I would like to simulate a bet size of 100
assertEquals(900, round.getPlayer().getBalance()); // default balance is 1000
}
【问题讨论】:
标签: java unit-testing testing junit