Test-Driven Development with Python.
Test-Driven Development with Python
TDD is a software development process that relies on repeating a very short cycle.
import unittest
def add(a, b):
return a + b
class TestMath(unittest.TestCase):
def test_add(self):
self.assertEqual(add(1, 2), 3)
self.assertEqual(add(-1, 1), 0)
TDD Cycle
- Write a failing test
- Write minimal code to pass
- Refactor the code