我已经被分配去测试这个Java方法,但似乎无法弄清楚该怎么做。有人可以帮忙吗?这是用于游戏实现的start()
方法:
public void start() {
Scanner sc = new Scanner(System.in);
boolean continueGame = true;
while (continueGame) {
reset();
play();
System.out.println("Do you want a rematch?(y/n)");
continueGame = sc.hasNextBoolean() ;
}
最佳答案
期待使用assertTrue(res)。使用函数将布尔值分配给while循环,并使结果在循环内为true。这样你可以使用assertTrue(res)
assertTrue在JUnit集合中
公共布尔isEqual(continueGame){
逻辑
虽然()
返回true;
}