class ClassTest(unittest.TestCase): def setUp(self): self.dog = Dog() self.cat = Cat() self.human = Human() self.car = Car() def test_dog_shall_bark(self): noise = self.dog.bark() expected_noise = "woof!" self.assertEqual(noise, expected_noise) def test_cat_shall_meow(self): noise = self.cat.meow() expected_noise = "meow!" self.assertEqual(noise, expected_noise) def test_human_shall_speak(self): noise = self.human.speak() expected_noise = "'hello'" self.assertEqual(noise, expected_noise) def test_car_shall_make_loud_noise(self): noise = self.car.make_noise(1) expected_noise = "vroom!" self.assertEqual(noise, expected_noise) def test_car_shall_make_very_loud_noise(self): noise = self.car.make_noise(10) expected_noise = "vroom!!!!!!!!!!" self.assertEqual(noise, expected_noise)
def setUp(self): self.dog = Dog() self.cat = Cat() self.human = Human() self.car = Car()
def test_cat_adapter_shall_make_noise(self): cat = Cat() cat_adapter = Adapter(cat, make_noise=cat.meow) noise = cat_adapter.make_noise() expected_noise = "meow!" self.assertEqual(noise, expected_noise)