# Tests that assert nothing, or assert a constant

*Tests and verification*: one of the ways AI coding agents bloat software, from lessloc's [pattern catalog](https://lessloc.org/patterns/index.md). lessloc catches it as [`empty-test`](https://lessloc.org/guide/reference.md#tier-1).

## What makes tests that assert nothing, or assert a constant a bad practice?

The standard that calls it a bad practice: Carr, TDD anti-patterns: The Liar.

## What does lessloc do about tests that assert nothing, or assert a constant?

lessloc catches it as [`empty-test`](https://lessloc.org/guide/reference.md#tier-1).

- `empty-test` (tier 1): A test that asserts nothing or only a constant, or one that mocks the code it tests.

## Examples

Caught as `empty-test`:

```python [tests/test_ae.py]
def test_total():
    total([1, 2])


def test_sum():
    assert True
```

Written well:

```python [tests/test_ae.py]
def test_total():
    assert total([1, 2]) == 3


def test_import_runs():
    import json
```

Caught as `empty-test`:

```python [tests/test_ag.py]
def test_render():
    expected = """\
[a]
b = 1
"""
    render(expected)
```

Written well:

```python [tests/test_ag.py]
def test_render():
    expected = """\
[a]
b = 1
"""
    assert render() == expected
```

Caught as `empty-test`:

```js [af.test.js]
import { test } from "node:test";
test("adds", () => {
  add(1, 2);
});
```

Written well:

```js [af.test.js]
import { test } from "node:test";
import assert from "node:assert";
test("adds", () => {
  assert.equal(add(1, 2), 3);
});
```

## Related patterns

The other patterns in [Tests and verification](https://lessloc.org/patterns/index.md#tests-and-verification):

- [Behavior added with no test changed in the same change](https://lessloc.org/patterns/untested.md): lessloc gives every session the rule: new behavior gets one focused test.
- [Deleted, skipped or force-passed tests](https://lessloc.org/patterns/weakened-tests.md): lessloc catches it as `weakened-tests`.
- [Test-only branches in production code](https://lessloc.org/patterns/test-logic.md): lessloc catches it as `test-logic`.
- [Tests that mock the code they test](https://lessloc.org/patterns/mocked-subject.md): lessloc catches it as `empty-test`.
- [Production code that branches on a value from the tests](https://lessloc.org/patterns/test-shaped.md): lessloc catches it as `test-logic`.
- [Stopping short: a requested function never written](https://lessloc.org/patterns/unaddressed.md): lessloc catches it as `unaddressed`: names a request asks to exist ("add a `--status` flag", "implement `export_csv()`") are looked for in the final repository; one that appears nowhere holds the turn.
- [Stopping short: part of the problem left failing](https://lessloc.org/patterns/unfinished.md): lessloc catches it as `unfinished`: in a turn that changed code, the agent's last reply is read sentence by sentence, with headings and lead-ins speaking for what is under them.
- [Saying "done" without a passing run on the final state](https://lessloc.org/patterns/index.md#unverified): lessloc catches it as `tests-failed` and `unverified`: the agent's own test runs, as its host reported them, are the evidence for the exact tree; a run that fails on the final state, or a change to how the tests run, holds the turn once, and a final state no run verified is written to the record; `lessloc test`, `verify` and `ci` record evidence too.
- [A refactor that changes existing tests](https://lessloc.org/patterns/refactor-tests.md): lessloc catches it as `refactor-tests`.
