Search

PythonReactSEOPDF
GitHub Skill

flutter-testing-standards

Unit, widget, and integration testing using mocktail and bloc_test.

HoangNguyen0403☆ 143 Repository stars48 Repository forks

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

View source ↗Guides

Skill instructions

Testing Standards

Priority: P1 (HIGH)

Ensuring code reliability through multi-layered testing strategies.

Structure

test/
├── unit/ # Business logic & mapping (Blocs, Repositories, UseCases)
├── widget/ # UI component behavior (Screens, Widgets)
└── integration/ # End-to-end flows

Implementation Guidelines

  • Testing Pyramid: Maintain ~70% Unit Tests, ~20% Widget Tests, ~10% Integration Tests.
  • Mocks: Use mocktail for type-safe, boilerplate-free mocking.
  • Unit Tests: Test logic in isolation. Verify all edge cases (Success, Failure, Exception).
  • Widget Tests: Test high-value interactions (Button clicks, Error states, Loading indicators).
  • BLoC Tests: Use blocTest to verify state emission sequences.
  • Code Coverage: Aim for 80%+ coverage on Domain and Presentation (Logic) layers.

Deep Dive References

🚫 Anti-Patterns

  • Thread Sleep: **No Future.delayed**: Use FakeAsync or expectations for deterministic timing.
  • Missing Assertions: **No "Execution Only" Tests**: A test without an expect() call is invalid.
  • Over-Mocking: **No Mocking Data Classes**: Use real instances for Entities/Models; mock only I/O.
  • Test Pollution: **No Shared State**: Ensure every test is Independent (FIRST).

Related Topics

layer-based-clean-architecture | dependency-injection | cicd

Examples

Read the usage examples in the source repository.

View source ↗

Source history

Indexed on
2026-01-20
Index updated
2026-01-26
Branch
main

Index and sync dates describe this directory. View the source repository for code history.

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!