dart-lang / mockito

Mockito-inspired mock library for Dart
https://pub.dev/packages/mockito
Apache License 2.0
623 stars 160 forks source link

I configured build.yaml as this repo, but it's not working as I expected #693

Open HeronKyaw opened 9 months ago

HeronKyaw commented 9 months ago

I created a build.yaml as this but it's not creating a mock directory. I have tried many ways but none of them is working. is it because I need some configuration or plugins? Everything else is working fine. Here's my code:

targets:
  $default:
    builders:
      mockito|mockBuilder:
        generate_for:
          - test/**.dart
        options:
          build_extensions:
            '^test/{{}}.dart' : 'test/mocks/{{}}.mocks.dart'

builders:
  mockBuilder:
    import: "package:mockito/src/builder.dart"
    builder_factories: ["buildMocks"]
    build_extensions: {".dart": [".mocks.dart"]}
    build_to: source
    auto_apply: dependents
    defaults:
      generate_for: ['test/**']

here's my pubspec.yaml -

dev_dependencies:
    mockito: 5.4.2
    build_runner: ^2.4.6

Before generating -

└── test
    └── example_bloc_test.dart

After generating -

└── test
    ├── example_bloc_test.dart
    └── example_bloc_test.mocks.dart

What it is supposed to be -

└── test
    ├── example_bloc_test.dart
    └── mock
        └── example_bloc_test.mocks.dart

Thanks.

KevalPrajapati commented 8 months ago

Facing the same issue. Trying with the build.yaml provided in the docs.

And having the same folder and file structure as the example given by @HeronKyaw.