Mobile 1,209 installs

Testing Dart and Flutter Applications

by dart-lang/skills

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…

Skill content

Testing Dart and Flutter Applications

Contents

- Structuring Test Files

- Writing Tests

- Executing Tests

- Test Implementation Workflow

- Examples

Structuring Test Files

Organize test files to mirror the lib directory structure to maintain predictability.

- Place all test code within the test directory at the root of the package.

- Append _test.dart to the end of all test file names (e.g., lib/src/utils.dart should be tested in test/src/utils_test.dart).

- If writing integration tests, place them in an integration_test directory at the root of the package.

Writing Tests

Utilize package:test as the standard testing library for Dart applications.