# No Tautological Test

Why tautological tests miss bugs, with complete bad, good, and corrected examples.

Source: https://www.jehlaniluciano.com/post/tautological-tests/

A tautological test checks code against itself. It can pass even when the answer is wrong.

Tell your agent to avoid these tests. Expected answers should come from the requirement.

For example: **a $100 entry with a 10% profit target should produce $110.**

These simplified examples contain a deliberate bug. In Python, `*` means multiply, and `assert` checks whether a statement is true.

**Bad test: the function supplies both answers.**

```python
def target_price(entry):
    return entry * 0.10  # Bug: calculates only the $10 profit.

actual = target_price(100)    # 10
expected = target_price(100)  # 10

assert actual == expected    # Passes despite the bug.
```

**Good test: the requirement supplies the expected answer.**

```python
def target_price(entry):
    return entry * 0.10  # Same bug.

actual = target_price(100)  # 10
expected = 110             # $100 entry + $10 profit.

assert actual == expected  # Fails and detects the bug.
```

Fix the function by adding the entry price:

```python
def target_price(entry):
    return entry + (entry * 0.10)

assert target_price(100) == 110  # Passes with the correct result.
```

Add this to your `AGENTS.md`:

```markdown
- Reject tautological tests.
```

Published: 2026-10-14
Updated: 2026-10-15
