39 / 87 · 02 AI-Augmented Test Design · Common AI Test Failures← prev⊞ allnext →☰ Read as one page
7.2Failure Mode 1: The Tautology Test
A tautology test tests the mock, not the code. It asserts that a value you explicitly set up is returned -- which will always be true regardless of whether the actual code works.
# THE TAUTOLOGY -- this tests nothing
def test_get_user(mock_db):
mock_db.get_user.return_value = {"name": "Alice"}
result = get_user(1)
assert result["name"] == "Alice" # This tests the mock, not the code
Why AI generates this: The LLM sees a pattern of "set up data, call function, check data" and fills it in without considering whether the assertion is meaningful.
How to detect it: For every assertion, trace the value backward. If the expected value comes directly from the test's own setup (without passing through production code), it is a tautology.
How to fix it:
# FIXED: test the actual behavior
def test_get_user_returns_formatted_name(mock_db):
mock_db.get_user.return_value = {"first_name": "Alice", "last_name": "Smith"}
result = get_user(1)
# Now we test that get_user() formats the name correctly
assert result["display_name"] == "Alice Smith"
assert result["initials"] == "AS"
Tautology Variants
The echo tautology:
def test_create_order(client):
payload = {"product_id": "abc", "quantity": 2}
response = client.post("/orders", json=payload)
body = response.json()
assert body["product_id"] == "abc" # Just echoing the input
assert body["quantity"] == 2 # Just echoing the input
# Missing: assert body["status"] == "pending" (actual business logic)
# Missing: assert body["total"] == 19.98 (calculated value)
# Missing: assert "id" in body (generated value)
The pass-through tautology:
def test_transform_data(mock_api):
mock_api.fetch.return_value = [1, 2, 3]
result = transform_data()
assert result == [1, 2, 3] # If transform_data just returns the raw data,
# this test catches nothing about the transform