Bug 523 - It is found that, after the game is forced to stop, the status "gameStarted" is not be set to false
Summary: It is found that, after the game is forced to stop, the status "gameStarted" ...
Status: CONFIRMED
Alias: None
Product: CS3343 2020 Group 9_Chinese Chess
Classification: Unclassified
Component: ChessGame (show other bugs)
Version: V2.0
Hardware: PC Mac OS
: --- enhancement
Deadline: 2020-11-13
Assignee: Marco
URL:
Depends on:
Blocks:
 
Reported: 2020-12-06 15:33 HKT by FENG Yi
Modified: 2020-12-06 23:15 HKT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description FENG Yi 2020-12-06 15:33:50 HKT
Steps to Reproduce:

If test cases in the other file have been run before the test algoTest0() (code is below)

@Test
public void algoTest0() throws Exception { // Game Not Start for CmdHelp
  ChessBoard board = ChessBoard.getInstance();
  board.stopGame();
  setOutput();
  CommandHandler.inputCommand(new String[]{"help"});
  assertEquals(true, getOutput().contains("The game has not started yet!"));
}

Actual Result:
The console prompt "The game is over! Help function is not allowed. Please start a new game."

Expected Result:
The game has not started yet!
Comment 1 DUAN Longteng 2020-12-06 23:15:56 HKT
(In reply to FENG Yi from comment #0)
> Steps to Reproduce:
> 
> If test cases in the other file have been run before the test algoTest0()
> (code is below)
> 
> @Test
> public void algoTest0() throws Exception { // Game Not Start for CmdHelp
>   ChessBoard board = ChessBoard.getInstance();
>   board.stopGame();
>   setOutput();
>   CommandHandler.inputCommand(new String[]{"help"});
>   assertEquals(true, getOutput().contains("The game has not started yet!"));
> }
> 
> Actual Result:
> The console prompt "The game is over! Help function is not allowed. Please
> start a new game."
> 
> Expected Result:
> The game has not started yet!

The bug is located at the stopGame() function in ChessBoard.java. It does not change the isStart value to false, which will lead to wrong output of this test case. Now new logic is added to make isStart false, the bug is resolved.