{"slug": "testing-rules-for-ai-agents", "title": "Testing rules for AI agents", "summary": "An engineer published a set of testing rules for AI agents, emphasizing behavior-driven testing, clear separation of happy path, edge, error, and non-goal scenarios, and strict guidelines for mocking and test maintenance. The rules aim to improve reliability and clarity in AI agent development.", "body_md": "| # Testing Rules for AI Agents | |\n| ## Intent | |\n| - Never decide what \"correct\" means on your own. Ask for the behavior, or work from the scenarios you were given. | |\n| - Before writing code, propose behavior scenarios — group them as happy path / edge / error / non-goals — and wait for the human to approve, cut, and add to them. | |\n| ## Writing tests | |\n| - Test behavior, not implementation. The test should describe what the system does, never how the code is structured inside. | |\n| - Name the test after the behavior. The body is setup → action → expected result. | |\n| - A test must be able to fail. Write it first and watch it go red, or temporarily break the implementation to confirm it fails — a test you've never seen fail proves nothing. | |\n| - Mock only what you don't own (network, clock, filesystem, third-party APIs). Let the real domain code run. | |\n| - Never write a test that just confirms the current (possibly buggy) behavior. If there's no approved spec, ask before asserting. | |\n| ## Maintaining tests | |\n| - When a test fails, read the message and fix the code — don't edit the test to make it pass unless the expected behavior actually changed. | |\n| - If a refactor breaks a test but the behavior didn't change, the test was wrong — fix the test's coupling, don't chase the implementation. | |\n| - Keep failures specific: assert on meaningful values and messages, so the next failure says what broke, not just \"expected true, got false.\" | |\n| ## Structure | |\n| - Put shared setup behind helpers written in domain language; hide noise, never meaning. | |\n| - Split tests by feature or behavior. Don't append everything to one giant file. | |\n| - Match the existing good tests in the repo — they are the template. If none exist, ask the human to seed the first ones. |", "url": "https://wpnews.pro/news/testing-rules-for-ai-agents", "canonical_source": "https://gist.github.com/jakubjanczyk/e9fb16d88b5b69d6ac8671c42fb86f4a", "published_at": "2026-07-01 21:16:56+00:00", "updated_at": "2026-07-09 09:41:07.373423+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-safety"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/testing-rules-for-ai-agents", "markdown": "https://wpnews.pro/news/testing-rules-for-ai-agents.md", "text": "https://wpnews.pro/news/testing-rules-for-ai-agents.txt", "jsonld": "https://wpnews.pro/news/testing-rules-for-ai-agents.jsonld"}}