Skill站外收录 @skilllib/skill-2117939930272415711
flutter-test-runner
执行 Flutter 项目的单元、组件及集成测试,验证核心逻辑与平台功能的正确性,生成覆盖报告并提供质量反馈,适用于代码变更后的自动化验证与持续集成流程。
测试与安全 AI 技能
Skills.MD
# Flutter Test Runner
## Purpose
This skill helps run and manage Sanmill's Flutter test suite, ensuring code quality and functional correctness.
## Use Cases
- Run unit and widget tests
- Run integration tests with real AI engine
- Generate and view test coverage reports
- Verify functionality after code modifications
- Validate changes in CI/CD pipelines
## Test Structure Overview
```
src/ui/flutter_app/
├── test/ # Unit and widget tests (Dart VM, fast)
├── integration_test/ # Integration tests (real platform + AI engine)
└── test_driver/ # Test drivers
```
## Quick Commands
### Unit and Widget Tests
```bash
cd src/ui/flutter_app
# Run all tests
flutter test
# Run specific test file
flutter test test/game/position_test.dart
# Run with coverage
flutter test --coverage
```
### Integration Tests
```bash
# From repository root - use the project script (recommended)
./run-integration-test.sh --full # Complete test suite
./run-integration-test.sh --single # Single test case
./run-integration-test.sh --help # Show options
# Manual execution (from src/ui/flutter_app)
flutter test integration_test/ -d linux # Linux
flutter test integration_test/ -d macos # macOS
flutter test integration_test/ -d windows # Windows
```
## Test Types Comparison
| Type | Environment | Native Code | Speed | Use For |
|------|-------------|-------------|-------|---------|
| **Unit/Widget** | Dart VM | ❌ No | ⚡ Fast | Pure Dart logic, UI components |
| **Integration** | Real platform | ✅ Yes | 🐌 Slower | AI behavior, platform features |
**Key difference**: Integration tests use the real C++ AI engine and must run on actual platforms, not the Dart VM.
## Coverage Reports
```bash
# Generate coverage
flutter test --coverage
# View summary (requires lcov)
lcov --summary coverage/lcov.info
# Generate HTML report
genhtml coverage/lcov.info -o coverage/html
# Then open coverage/html/index.html
```
**Coverage targets**: Overall ≥80%, Critical logic ≥90%, UI ≥70%
## Common Issues & Solutions
### 1. MissingPluginException
- **Symptom**: Tests fail with plugin errors
- **Cause**: Running integration tests with `flutter test test/`
- **Fix**: Use `flutter test integration_test/ -d <platform>`
### 2. Import Errors
- **Fix**: Run `flutter pub get` or `flutter clean && flutter pub get`
### 3. Integration Test Failures (AI-related)
- **Cause**: AI behavior may vary between runs
- **Solution**:
1. Check if AI moves are reasonable
2. Update expected sequences in test data if needed
3. Ensure consistent AI configuration
### 4. Timeout Issues
- Increase test timeout in test configuration
- Check async operation handling
- Adjust `maxWaitTimeMs` for AI tests
## Best Practices
1. **Run unit tests frequently** - Fast feedback loop
2. **Run integration tests before commits** - Catch platform-specific issues
3. **Check coverage for new code** - Maintain quality standards
4. **Keep tests independent** - Tests should not depend on each other
5. **Update expectations carefully** - For AI tests, verify moves are actually correct
## Reference Documentation
- **Integration tests**: `src/ui/flutter_app/integration_test/AUTOMATED_MOVE_TESTS_README.md`
- **Flutter testing guide**: https://docs.flutter.dev/testing
- **Test directories**: `src/ui/flutter_app/test/` and `src/ui/flutter_app/integration_test/`
## Output Format
Test results should report:
- ✓ Pass/fail status with counts
- ✗ Failure details with stack traces
- 📊 Coverage percentage (if generated)
- ⏱ Execution time
- 💡 Actionable recommendations
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「flutter-test-runner」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次