Always use isTrue and isFalse matchers instead of bare true and false.
Never use equals(); test against the value directly.
Code Generation Testing
PREFER object introspection over string testing for generated code:
Test constructor/method existence: combinedClass.constructors.firstWhere((c) => c.name == 'fromSimple').
Test parameter types: parameter.type?.accept(emitter).toString().
Test method properties: method.lambda, method.returns.
Test field names: combinedClass.fields.map((f) => f.name).
Only use contains(collapseWhitespace(...)) when absolutely necessary for testing specific generated code content.
NEVER use bare contains() without collapseWhitespace() for generated code — formatting differences will cause flaky tests.
Use collapseWhitespace from test package: import 'package:test/test.dart';.
When testing generated code strings, format both expected and actual with DartFormatter.
String Testing Guidelines
When testing generated code strings:
ALWAYS test full method/function bodies, never fragments or individual lines.
Format both expected and actual with DartFormatter before comparing.
Compare using collapseWhitespace(actual) == collapseWhitespace(expected) for full body equality.
When a generator returns List<Code> (statements), wrap them in a Method to produce a complete formattable body, then test the full body.
When a generator returns an Expression, wrap it in a complete method context before comparing.
NEVER use bare contains() for generated code — always use full body comparison or contains(collapseWhitespace(...)) on a formatted complete body.
NEVER test code fragments (e.g., checking if output "contains 'FormData()'" or "contains '.toJson()'"). Always assert on the complete expected output.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: t-unit-tonik-testing3description: Testing Conventions4---56# Testing Conventions78## Matchers910- Always use `isTrue` and `isFalse` matchers instead of bare `true` and `false`.11- Never use `equals()`; test against the value directly.1213## Code Generation Testing1415- **PREFER object introspection** over string testing for generated code:16 - Test constructor/method existence: `combinedClass.constructors.firstWhere((c) => c.name == 'fromSimple')`.17 - Test parameter types: `parameter.type?.accept(emitter).toString()`.18 - Test method properties: `method.lambda`, `method.returns`.19 - Test field names: `combinedClass.fields.map((f) => f.name)`.2021- **Only use `contains(collapseWhitespace(...))` when absolutely necessary** for testing specific generated code content.22- **NEVER use bare `contains()` without `collapseWhitespace()`** for generated code — formatting differences will cause flaky tests.23- Use `collapseWhitespace` from [test package](https://pub.dev/packages/test): `import 'package:test/test.dart';`.24- When testing generated code strings, format both expected and actual with `DartFormatter`.2526## String Testing Guidelines2728- When testing generated code strings:29 - **ALWAYS test full method/function bodies**, never fragments or individual lines.30 - Format both expected and actual with `DartFormatter` before comparing.31 - Compare using `collapseWhitespace(actual) == collapseWhitespace(expected)` for full body equality.32 - When a generator returns `List<Code>` (statements), wrap them in a `Method` to produce a complete formattable body, then test the full body.33 - When a generator returns an `Expression`, wrap it in a complete method context before comparing.34 - **NEVER use bare `contains()` for generated code** — always use full body comparison or `contains(collapseWhitespace(...))` on a formatted complete body.35 - **NEVER test code fragments** (e.g., checking if output "contains 'FormData()'" or "contains '.toJson()'"). Always assert on the complete expected output.3637---38> Converted and distributed by [TomeVault](https://tomevault.io/claim/t-unit) — claim your Tome and manage your conversions.39<!-- tomevault:4.0:skill_md:2026-04-11 -->
Run npx skillmds@latest add tomevault-io/t-unit-tonik-testing in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Testing Conventions It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.