def test_playMatchAndPlayerBWins(self): self.createPlayers(ZERO, ZERO) self.match = Match() self.match.playMatch(self.playerA, self.playerB, Play("B")) self.assertTrue(self.playerB.isWinner()) self.assertTrue(self.playerA.hasNoPoints())
def test_randomTesting(self): self.createPlayers(ZERO, ZERO) r = RandomPlay() self.match = Match() self.match.playMatch(self.playerA, self.playerB, r) if r.getMostScoredPlayer() == "B": self.assertTrue(self.playerB.isWinner()) self.assertFalse(self.playerA.isWinner()) else: self.assertTrue(self.playerA.isWinner()) self.assertFalse(self.playerB.isWinner())
class TestMatch(TestBase): def test_playMatchAndPlayerAWins(self): self.createPlayers(ZERO, ZERO) self.match = Match() self.match.playMatch(self.playerA, self.playerB, Play("A")) self.assertTrue(self.playerA.isWinner()) self.assertTrue(self.playerB.hasNoPoints()) def test_playMatchAndPlayerBWins(self): self.createPlayers(ZERO, ZERO) self.match = Match() self.match.playMatch(self.playerA, self.playerB, Play("B")) self.assertTrue(self.playerB.isWinner()) self.assertTrue(self.playerA.hasNoPoints()) def test_randomTesting(self): self.createPlayers(ZERO, ZERO) r = RandomPlay() self.match = Match() self.match.playMatch(self.playerA, self.playerB, r) if r.getMostScoredPlayer() == "B": self.assertTrue(self.playerB.isWinner()) self.assertFalse(self.playerA.isWinner()) else: self.assertTrue(self.playerA.isWinner()) self.assertFalse(self.playerB.isWinner()) # Esta prueba es util para descubrir dependencias de codigo y # mejorar la organizaciĆ³n interna # Nos damos cuenta de quĆ© es comun y que hay que cmabiar # entre cada partido def test_randomTestingManyMatches(self): self.match = Match() tests = 100000 for x in range(tests): r = RandomPlay() self.createPlayers(ZERO, ZERO) self.match.playMatch(self.playerA, self.playerB, r) if r.getMostScoredPlayer() == "B": self.assertTrue(self.playerB.isWinner()) self.assertFalse(self.playerA.isWinner()) #print("Score A:" , self.playerA.getScore(), " Score B:", self.playerB.getScore()) else: self.assertTrue(self.playerA.isWinner()) self.assertFalse(self.playerB.isWinner()) #print("Score A:" , self.playerA.getScore(), " Score B:", self.playerB.getScore()) print(tests, " random tenis games done.")
def test_randomTestingManyMatches(self): self.match = Match() tests = 100000 for x in range(tests): r = RandomPlay() self.createPlayers(ZERO, ZERO) self.match.playMatch(self.playerA, self.playerB, r) if r.getMostScoredPlayer() == "B": self.assertTrue(self.playerB.isWinner()) self.assertFalse(self.playerA.isWinner()) #print("Score A:" , self.playerA.getScore(), " Score B:", self.playerB.getScore()) else: self.assertTrue(self.playerA.isWinner()) self.assertFalse(self.playerB.isWinner()) #print("Score A:" , self.playerA.getScore(), " Score B:", self.playerB.getScore()) print(tests, " random tenis games done.")