Modern QA2026Failure Mode 3: The Overly Specific Assertion — tiles
Log inJoin
41 / 87 · 02 AI-Augmented Test Design · Common AI Test Failures← prev⊞ allnext →☰ Read as one page

7.4Failure Mode 3: The Overly Specific Assertion

The test asserts exact error message text, timestamps, or auto-generated IDs that change between runs.

# BRITTLE: depends on exact error message text
assert error.message == "Invalid email: 'notanemail' does not match RFC 5322 format"

# BRITTLE: depends on exact timestamp
assert order.created_at == "2026-02-09T10:30:00Z"

# BRITTLE: depends on auto-generated ID format
assert user.id == "usr_a1b2c3d4e5f6"

Why AI generates this: The LLM produces concrete values because they look like realistic test assertions. It does not reason about which values are deterministic and which are generated at runtime.

How to fix it:

# RESILIENT: checks type and content, not exact string
assert isinstance(error, ValidationError)
assert "email" in str(error).lower()

# RESILIENT: checks existence and recency
assert order.created_at is not None
assert (datetime.now(UTC) - order.created_at).seconds < 5

# RESILIENT: checks format, not exact value
assert user.id is not None
assert user.id.startswith("usr_")
assert len(user.id) == 16