Mockito generates mocks for all classes listet within the @GenerateMocks
annotatio. It does so for tests in the test
folder but it doesn't for tests in the integration_test
folder. How do I change that?
Add a build.yaml file with the following content to your project root folder.
targets:
$default:
sources:
- $package$
- lib/$lib$
- lib/**.dart
- test/**.dart
- integration_test/**.dart
builders:
mockito|mockBuilder:
generate_for:
- test/**.dart
- integration_test/**.dart
Both generate_for
and sources
are needed to tell the mockBuilder which files should be processed.
The generate_for
configuration is only a subset of the all the files used by the builder. But these files do not include the integration_test folder by default. To modify that, we can list the sources files manually. We have to include the default sources $package$
and lib/$lib$
, or we will get warnings if not.
By including any folder - in our case 'integration_test' it will then also be available to generate_for
.
Here is the excerpt from the build_config/README.md:
sources
which should have this Builder applied. See sources
configuration above for how to configure this.and:
include
and exclude
. Any file which matches
any glob in include
and no globs in exclude
is considered a source of the
target. When include
is omitted every file is considered a match.