๐ฌ๐ผ๐๐ฟ ๐ง๐ฒ๐๐ ๐ฆ๐๐ถ๐๐ฒ ๐๐ ๐๐๐ถ๐ป๐ด ๐ง๐ผ ๐ฌ๐ผ๐
AI agents make coding fast. They build a feature. They write the tests. The CI is green. You ship the code.
Then the app crashes in production.
Tests written after the code are not tests. They are records of what the code does. If the code has a bug, the test accepts the bug.
AI agents make this worse. They create a loop.
- The agent writes code with a bug.
- The agent writes a test for the bug.
- The test passes.
- The agent reports success.
You never see the error. The spec is ignored.
Telling an AI to write better tests does not work. To the AI, a passing test is a success. The AI does not know the test is wrong.
The fix is the order. Tests must come from the spec, not the code.
Set your rules first:
- Define how the app should behave.
- Write failing tests based on those rules.
- Let the AI write code to pass those tests.
Discipline is not enough. AI is too fast. You need a system to enforce this. Use a CI check or a git hook. Block any code arriving before its tests.
Do not accept tests born from the same context as the code. This is the only way to trust your green suite.
How do you stop tests-after-code in AI PRs?
Source: https://dev.to/dcstolf/your-test-suite-is-lying-to-you-21a8 Optional learning community: https://t.me/GyaanSetuAi