# Testing AI-Generated Code: Lint the Pattern, Test the Decision

DevFeed: [Testing AI-Generated Code: Lint the Pattern, Test the Decision](<https://devfeed.tech/articles/testing-ai-generated-code-lint-the-pattern-test-the-decision-92573.md>)

Original publisher: [Read original article](<https://www.robinwieruch.de/testing-ai-generated-code/>)

Author: Robin Wieruch

Published: 2026-10-21T06:50:46Z

Content type: article

Language: en

Sources: [Robin Wieruch](<https://devfeed.tech/sources/robin-wieruch.md>)

Topics: [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [lint](<https://devfeed.tech/topics/lint.md>), [AI-assisted coding](<https://devfeed.tech/topics/ai-assisted-coding.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>), [coding patterns](<https://devfeed.tech/topics/coding-patterns.md>)

Tags: [agentic-engineering](<https://devfeed.tech/tags/agentic-engineering.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-engineer](<https://devfeed.tech/tags/ai-engineer.md>), [ai-generated-tests](<https://devfeed.tech/tags/ai-generated-tests.md>), [coding-agents](<https://devfeed.tech/tags/coding-agents.md>), [lint](<https://devfeed.tech/tags/lint.md>), [lint-rules-for-ai-agents](<https://devfeed.tech/tags/lint-rules-for-ai-agents.md>), [pattern](<https://devfeed.tech/tags/pattern.md>), [software-factory](<https://devfeed.tech/tags/software-factory.md>), [test](<https://devfeed.tech/tags/test.md>), [testing](<https://devfeed.tech/tags/testing.md>), [testing-ai-generated-code](<https://devfeed.tech/tags/testing-ai-generated-code.md>)

## AI overview

The article's approach is to enforce each file type's documented skeleton with lint, centralize test setup in a shared harness, and test only files that make decisions beyond that pattern. For handlers, lint checks session-first ordering, service calls inside try/catch, error mapping, and safe input flow; it covers every handler and makes tests for those invariants redundant. A shared harness fakes external effects and uses the real generated backend client over an in-memory transport, with safeguards for unserved methods, fake crashes, and production request limits. Tests focus on requests, results, side effects, branches, security choices, and failure behavior. The approach also applies to forms and comboboxes, while some file types need no harness or individual tests. It targets useful unit and integration coverage, not a fully tested codebase; end-to-end testing is outside the article's scope.

## Source excerpt

Testing AI-generated code without the noise: lint the patterns coding agents follow, share one test harness, and add tests only where a file leaves its pattern.