一键导入
create-test
Process for creating unit and widget tests in the test/ directory mirroring the lib/src/ directory structure. Covers using Mockito.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Process for creating unit and widget tests in the test/ directory mirroring the lib/src/ directory structure. Covers using Mockito.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Process for creating mock data sources in the infrastructure layer.
Process for building, exporting, and registering reusable UI components in the packages/app_ui package. References design-to-code.md for design tokens (typography, colors, spacing).
Outlines the process for converting Figma designs into a structured, platform-aware Flutter implementation.
Use when completely removing the web platform from the project. Details how to delete directories/configurations, clean up app_ui web components, remove web-specific feature views (*_view_web.dart), prune conditional imports/logic, and run validation.
Use when asked to add, update, or group routes using GoRouter, or manage redirection guards.
Step-by-step workflow for creating, configuring, and updating Flutter golden tests using the Alchemist package.
| name | create-test |
| description | Process for creating unit and widget tests in the test/ directory mirroring the lib/src/ directory structure. Covers using Mockito. |
This skill defines the process for writing and running unit and widget tests in the project.
Test files must mirror the lib/src/ directory hierarchy under test/:
lib/src/
└── infrastructure/
└── auth/
└── auth_repository.dart
test/src/
└── infrastructure/
└── auth/
└── auth_repository_test.dart
All test files must end with the _test.dart suffix.
mockito package for mocking infrastructure and
external client dependencies.@GenerateMocks to auto-generate mocks
using build_runner.Annotate your test file's main() method with the dependencies to mock:
import 'package:apple_project/src/infrastructure/auth/auth_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
// Import the generated mock file (ends with .mocks.dart)
import 'auth_repository_test.mocks.dart';
@GenerateMocks([AuthRepository])
void main() {
// Test code goes here
}
To build/generate the mock implementation, run:
melos run generate
Structure tests logically using group, test, and standard Mockito APIs:
void main() {
late MockAuthRepository mockAuthRepo;
setUp(() {
mockAuthRepo = MockAuthRepository();
});
group('AuthRepository Tests', () {
test('login returns success on correct credentials', () async {
// Arrange
when(mockAuthRepo.login('user', 'pass'))
.thenAnswer((_) async => const Ok(null));
// Act
final result = await mockAuthRepo.login('user', 'pass');
// Assert
expect(result.isOk, isTrue);
verify(mockAuthRepo.login('user', 'pass')).called(1);
});
});
}
flutter test
flutter test test/src/infrastructure/auth/auth_repository_test.dart