Skip to content

Instantly share code, notes, and snippets.

@blaix
Last active August 29, 2015 13:56
Show Gist options
  • Save blaix/8790733 to your computer and use it in GitHub Desktop.
Save blaix/8790733 to your computer and use it in GitHub Desktop.
def test_returns_2_when_x_is_1_and_y_is_1(self):
self.assertEqual(2, sum(1, 2))
def test_returns_1_when_x_is_2_and_y_is_neg1(self):
self.assertEqual(1, sum(2, -1))
# etc....
# versus:
def test_adds_two_integers(self):
self.assertEqual(2, sum(1, 2))
self.assertEqual(1, sum(2, -1))
# etc...
# you may have heard "only assert one thing"
# that doesn't always mean only have one literal assertion call in your test
# it means only have one logical assertion
# i.e. test the smallest unit of logic that matters
# that sometimes requires multiple assert calls for very low-level functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment