defuncart / dart_test_utils

A dart tool containing test utils.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dart_test_utils

A dart tool contain test utils.

Installation

The tool can be installed via dart pub global by activate the package on your local machine:

dart pub global activate --source git https://github.com/defuncart/dart_test_utils

Similarly, the tool can be uninstalled via dart pub global deactivate dart_test_utils. Alternatively, the tool can be a depended upon in a dart/flutter project:

dev_dependencies:
    dart_test_utils:
        git: https://github.com/defuncart/dart_test_utils

Organize Test Folder

This tools re-organizes the file structure of /test to match lib.

For instance, if the file structure was

lib/
├─ features/
│  ├─ feature_1/
│  │  ├─ feature_1_repository.dart
test/
├─ feature_1_repository_test.dart

then

test/feature_1_repository_test.dart would be moved into test/features/feature_1/feature_1_repository_test.dart.

Usage

dart pub global run dart_test_utils:organize_test_folder --apply

or

dart run dart_test_utils:organize_test_folder --apply

if the tool is a dev dependency.

The option --set-exit-if-changed can be used in a CI pipeline to fail when there are file changes. For a full overview, see dart run dart_test_utils:organize_test_folder -h.

Expected Behavior

  • When a file should be moved, if a file exists at the target location, then the existing file will be overwritten.
  • If a moved file contains relative paths (i.e. import '../mocks.dart'), then the path will need manual resolution.

About

A dart tool containing test utils.

License:MIT License


Languages

Language:Dart 100.0%