im starting to learn TDD and got the Bowling Game kata as exercise. I have completed some of the regular score test, but i want to add more just to practice and one idea was to raise an exception if i roll a negative number.
The hole code is not relevant because this is a simple validation
class BowlingGame(object):
def __init__(self):
pass
def roll(self, pins):
if pins < 0:
#Want to Return Value Exception
class BowlingGameTest(unittest.TestCase):
def setUp(self):
self._game = BowlingGame()
def test_roll_negative(self):
self.game.roll(-1)
#Want to catch exception here with self.assert or except
The problem is that if i return for example 0/0 the exception is raised in the BowlingGame class and not in the BowlingGameTest class (there are in two diferent files).
If i do return ValueError (BowlingGame Class) with self.assertRaises(ValueError): (BowlingGameTest Class) i got AssertionError: ValueError not raised
Any ideas?