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

7.7Failure Mode 6: The Assertion-Free Test

The test runs code but never asserts anything. It only proves the code does not throw an exception.

# USELESS: no assertion
def test_process_order():
    order = create_order(product_id="abc", quantity=2)
    process_order(order)
    # Test passes as long as no exception is raised
    # But what if the order was not actually processed?

How to detect it: Search for test functions with no assert, raises, or expect statements.

# Find assertion-free tests
grep -rn "def test_" tests/ | while read line; do
    func=$(echo "$line" | sed 's/.*def \(test_[a-z_]*\).*/\1/')
    file=$(echo "$line" | cut -d: -f1)
    if ! grep -A 20 "def $func" "$file" | grep -q "assert\|raises\|pytest.mark"; then
        echo "WARNING: $func in $file has no assertion"
    fi
done

How to fix it: Every test must assert something specific about the outcome.