dart-testing
Testing Dart Applications
Contents
- Core Testing Principles
- Test Implementation Guidelines
- Mocking and Isolation
- Running Tests
- Workflows
- Examples
- Related Skills
Core Testing Principles
Apply the appropriate testing strategy based on the target environment and scope:
- Unit Tests: Verify the smallest piece of testable software (functions, methods, classes). Maximize coverage here.
- Component/Widget Tests: Verify that a component (multiple classes or Flutter Widgets) behaves as expected. Use mock objects to mimic user actions and events.
- Integration/End-to-End Tests: Verify the behavior of an entire app or large subsystem on a simulated/real device or browser.
Conditional Logic for Test Environments:
More from dart-lang/skills
dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
2.1Kdart-fix-runtime-errors
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
2.1Kdart-run-static-analysis
Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.
2.0Kdart-use-pattern-matching
Use switch expressions and pattern matching where appropriate
2.0Kdart-resolve-package-conflicts
Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.
2.0Kdart-collect-coverage
Collect coverage using the coverage packge and create an LCOV report
2.0K