I have been writing a simple connect four game in python today. I intend for the game to have comprehensive tests.
I have written tests for all of my methods besides the main game loop. I am unsure of how to write an effective test for the main game loop.
In the below function:
-
self.move gets the player's move and puts it into the game board; and
-
is_game_complete() returns a bool depending on whether the game is complete.
Both of the above have effective tests.
I am unsure of how to write a useful test for the below. Is a test appropriate?
def game_loop(self):
while True:
for active_player in self.players:
self.move(active_player)
if self.game_checker.is_game_complete():
return active_player
I expect that there is a neat way to write a test, or that a test is unlikely to be useful here.
Thank you very much for any response.
Aucun commentaire:
Enregistrer un commentaire