flutter-test-gen

Generate mocktail unit tests from Dart code into the test/ directory.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/dus2183-commits/flutter-skills --skill flutter-test-gen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-test-gen
Source: https://github.com/dus2183-commits/flutter-skills/tree/main/flutter-test-gen
Command: npx skills add https://github.com/dus2183-commits/flutter-skills --skill flutter-test-gen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

该技能能够从 Dart 代码自动生成 mocktail 单元测试,显著提升测试覆盖率并减少重复编写测试的工作量。

它适用于读取 Dart 文件路径或直接粘贴代码片段的场景,并会输出放在 test/ 目录下的测试文件。

通过遵循统一的测试模板和 mock 机制,降低入门门槛、提高可维护性。

Core Features & Use Cases

  • 自动为公有方法生成三种测试用例:成功路径、异常路径、边界值。
  • 支持输入形式为文件路径或直接粘贴代码,并输出到 test/ 目录。
  • 使用 mocktail 框架,遵循统一的测试模板,便于团队协作与持续集成。

Quick Start

给出要测试的 Dart 代码片段或文件路径,Claude 将自动生成 mocktail 测试并输出到 test/ 目录。

Frequently Asked Questions about flutter-test-gen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automatically generate mocktail unit tests for Dart code?

To automatically generate mocktail unit tests for Dart code, provide a Dart file path or paste the code snippet, and the system analyzes class structures and dependencies to output ready-to-run tests into the test/ directory. It uses mocktail to locate dependencies and create mocks following a standardized template.

What testing patterns are used when generating Flutter unit tests?

The generated Flutter unit tests follow a three-test-per-public-method pattern, specifically covering the success path, exception path, and boundary values for each public method. This standardized approach ensures comprehensive test coverage and reduces the manual effort of writing repetitive test cases.

Can I generate unit tests from a Dart code snippet without providing a file path?

Yes, you can generate unit tests directly from a Dart code snippet without providing a file path. The system accepts both direct code snippets and file paths as input, analyzes the class structures, and outputs the resulting mocktail test files into the project's test/ directory.

Does the generated Dart mocktail test require any specific project conventions?

Yes, the generated Dart mocktail tests rely on project conventions and the mocktail framework to accurately locate dependencies and create mocks. The output is placed in the test/ directory, ensuring the tests integrate smoothly with team collaboration and continuous integration pipelines.

Why use mocktail for generating Dart unit tests instead of other mocking frameworks?

Using mocktail for generating Dart unit tests provides a standardized mocking mechanism without requiring code generation annotations, lowering the entry barrier. It follows a unified test template to create mocks and generate ready-to-run unit tests, which improves maintainability and facilitates team collaboration.