GCTAA Logo

Governor's Career & Technical Academy Arlington

Intro to Computer Science: Bowling Game TDD with Python


First Test

Unit Tests

from unittest import TestCase


class test_bowling_game(TestCase):

    def setUp(self):
        self.game = BowlingGame()

    def test_gutter_game(self):
        for roll in range(20):
            self.game.roll(0)
        self.assertEqual(self.game.score(), 0)

Code


Second Test

Unit Tests

from unittest import TestCase


class test_bowling_game(TestCase):

    def setUp(self):
        self.game = BowlingGame()

    def test_gutter_game(self):
        for roll in range(20):
            self.game.roll(0)
        self.assertEqual(self.game.score(), 0)

    def test_all_ones_game(self):
        for roll in range(20):
            self.game.roll(1)
        self.assertEqual(self.game.score(), 20)

Code