Modern QA2026Backward Compatibility Testing — tiles
Log inJoin
60 / 65 · 14 API Testing Fundamentals · API Versioning← prev⊞ allnext →☰ Read as one page

8.3Backward Compatibility Testing

The most important aspect of API versioning testing: old clients must not break when new versions launch.

def test_v1_still_works_after_v2_launch(api):
    """v1 endpoints must continue to function correctly."""
    # Create a user via v1
    r = api.post("/v1/users", json={"name": "Alice", "email": "alice@test.com"})
    assert r.status_code == 201

    # Read via v1
    user_id = r.json()["id"]
    r = api.get(f"/v1/users/{user_id}")
    assert r.status_code == 200
    assert r.json()["name"] == "Alice"

    # Delete via v1
    r = api.delete(f"/v1/users/{user_id}")
    assert r.status_code == 204

def test_v1_data_accessible_via_v2(api):
    """Data created in v1 should be accessible in v2 format."""
    # Create in v1 format
    r = api.post("/v1/users", json={"name": "Bob Smith", "email": "bob@test.com"})
    user_id = r.json()["id"]

    # Read in v2 format
    r = api.get(f"/v2/users/{user_id}")
    assert r.status_code == 200
    # v2 should correctly split the name
    assert r.json()["first_name"] == "Bob"
    assert r.json()["last_name"] == "Smith"

def test_v2_data_accessible_via_v1(api):
    """Data created in v2 should be accessible in v1 format."""
    r = api.post("/v2/users", json={
        "first_name": "Jane",
        "last_name": "Doe",
        "email": "jane@test.com"
    })
    user_id = r.json()["id"]

    # Read in v1 format
    r = api.get(f"/v1/users/{user_id}")
    assert r.status_code == 200
    assert r.json()["name"] == "Jane Doe"  # v1 should combine first/last