DEV Community

Maksym Danylenko
Maksym Danylenko

Posted on

Unit tests aren't useless. Bad unit tests are.

"Unit tests are worse than useless" got 327K views on X last week:

I get it. Most AI-written unit tests restate the code, always pass, and catch nothing. They break on every refactor and never find a real bug.

But the problem is bad tests, not unit tests.

77% of production failures can be reproduced by a unit test

A study of 198 production failures in Cassandra, HBase, HDFS, MapReduce and Redis (Yuan et al., OSDI '14) found that 77% could be reproduced by a unit test. Dropping unit tests for E2E-only throws that away.

You can let the agent write junk tests and then pay again to delete them. Or teach it to write tests that catch bugs from the start. We use unit tests skills for this: rules the agent loads when it writes tests.

Here are the ones we built: https://github.com/mavka-ai/unit-tests-skills

Top comments (0)