dart-test-fundamentals by kevmoo/dash_skills
npx skills add https://github.com/kevmoo/dash_skills --skill dart-test-fundamentals在以下情况下使用此技能:
group 组织测试套件时。dart_test.yaml 配置测试执行时。test 和 group)test:测试的基本单元。
test('描述', () {
// 断言
});
group:用于将测试组织成逻辑块。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
setUp 和 tearDown 调用的作用域。PascalCase(例如,group('MyClient', ...))。group 调用包裹所有测试。命名测试:
'抛出 StateError' 或 '将 API 密钥添加到 URL')。命名参数放置:
对于 test 和 group 调用,将命名参数(例如,testOn、timeout、skip)紧接在描述字符串之后、回调闭包之前放置。这通过将测试逻辑放在最后来提高可读性。
test('描述', testOn: 'vm', () {
// 断言
});
setUp, tearDown)setUp:在当前 group(以及嵌套组)中的每个 test 之前运行。tearDown:在当前 group 中的每个 test 之后运行。setUpAll:在组中任何测试之前运行一次。tearDownAll:在组中所有测试之后运行一次。最佳实践:
setUp 重置状态以确保测试隔离。dart_test.yaml)dart_test.yaml 文件用于配置测试运行器。常见配置包括:
定义测试运行的位置(vm、chrome、node)。
platforms:
- vm
- chrome
对测试进行分类以运行特定子集。
tags:
integration:
timeout: 2x
在代码中使用:
@Tags(['integration'])
import 'package:test/test.dart';
运行带标签的测试:dart test --tags integration
为测试设置默认超时时间。
timeouts:
2x # 默认超时时间的两倍
_test.dart 结尾,才能被测试运行器识别。test/ 目录下。dart test:运行所有测试。dart test test/path/to/file_test.dart:运行特定文件。dart test --name "子字符串":运行描述匹配的测试。dart-test-fundamentals 是用于构建和配置测试的核心技能。关于在这些测试中编写断言,请参考:
dart-matcher-best-practices:如果项目坚持使用传统的 package:matcher(expect 调用),请使用此技能。dart-checks-migration:如果项目正在迁移到现代的 package:checks(check 调用),请使用此技能。每周安装次数
134
代码仓库
GitHub 星标数
119
首次出现
2026年2月16日
安全审计
已安装于
codex74
antigravity62
claude-code47
github-copilot34
gemini-cli33
opencode33
Use this skill when:
group.dart_test.yaml.test and group)test : The fundamental unit of testing.
test('description', () {
// assertions });
group : Used to organize tests into logical blocks.
setUp and tearDown calls.PascalCase for groups that correspond to a class name (e.g., group('MyClient', ...)).group call if it's the only one.Naming Tests :
'throws StateError' or 'adds API key to URL').Named Parameters Placement :
For test and group calls, place named parameters (e.g., testOn, timeout, skip) immediately after the description string, before the callback closure. This improves readability by keeping the test logic last.
test('description', testOn: 'vm', () {
// assertions
});
setUp, tearDown)setUp : Runs before every test in the current group (and nested groups).tearDown : Runs after every test in the current group.setUpAll : Runs once before any test in the group.tearDownAll : Runs once after all tests in the group.Best Practice:
setUp for resetting state to ensure test isolation.dart_test.yaml)The dart_test.yaml file configures the test runner. Common configurations include:
Define where tests run (vm, chrome, node).
platforms:
- vm
- chrome
Categorize tests to run specific subsets.
tags:
integration:
timeout: 2x
Usage in code:
@Tags(['integration'])
import 'package:test/test.dart';
Running tags: dart test --tags integration
Set default timeouts for tests.
timeouts:
2x # Double the default timeout
_test.dart to be picked up by the test runner.test/ directory.dart test: Run all tests.dart test test/path/to/file_test.dart: Run a specific file.dart test --name "substring": Run tests matching a description.dart-test-fundamentals is the core skill for structuring and configuring tests. For writing assertions within those tests, refer to:
dart-matcher-best-practices : Use this if the project sticks with the traditional package:matcher (expect calls).dart-checks-migration : Use this if the project is migrating to the modern package:checks (check calls).Weekly Installs
134
Repository
GitHub Stars
119
First Seen
Feb 16, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex74
antigravity62
claude-code47
github-copilot34
gemini-cli33
opencode33
测试策略完整指南:单元/集成/E2E测试金字塔与自动化实践
11,200 周安装