Typerite
Menu
Test-Driven Development with Python

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

  1. Write a failing test
  2. Write minimal code to pass
  3. Refactor the code