-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
In #132346, @reidbaker suggested added a @visibleForTesting
annotation to Artifact
:
factory Artifacts.test({String? localEngine, FileSystem? fileSystem})
It wasn't as easy as expected, because it's also used by IMobileDevice
:
factory IMobileDevice.test({ required ProcessManager processManager }) {
return IMobileDevice(
artifacts: Artifacts.test(),
cache: Cache.test(processManager: processManager),
processManager: processManager,
logger: BufferLogger.test(),
);
}
After discussing with @christopherfujino on Discord:
yeah, i don't know the history, but i suspect that's the origen of the [Class].test() factories. For
Artifacts.test()
in particular, it references a private function, so that function will have to be made@visibleForTesting
.So, we have a
fakes.dart
file undertest/
, however, a lot of those are hard-coded to specific behavior, or have tons of configuration constructor parameters. Thus, at least for myself, when I need a new test type, I don't default to importing that library and trying to re-use. I'm not sure the right way to organize things so that we have good discoverability of general purpose test constructors.maybe the answer is to migrate those classes under
fakes.dart
that are pretty specific to a specific set of tests just to the test library that uses it
So, in other words:
- Migrate classes in
fakes.dart
that are only used by a specific test(s) to those tests - Move general testing utilities in
lib/**
totest/fakes.dart
- Consider updating documentation so folks have a chance in finding out how fakes should be setup in the tool
(I'm happy to contribute here, but it might take some time for this to rise to the top of the stack)