overrideForTesting static method
- @visibleForTesting
- CompileContext context = const _TestCompileContext()
Overrides CompileContext.current to return context
.
This can be done once during main()
or setUpAll(() => ...)
:
void main() {
CompileContext.overrideForTesting();
}
Or piece-meal per-test for custom behaviors:
void main() {
test('...', () {
CompileContext.overrideForTesting(flagSet1);
});
test('...', () {
CompileContext.overrideForTesting(flagSet2);
});
}
Implementation
@visibleForTesting
static void overrideForTesting([
CompileContext context = const _TestCompileContext(),
]) {
ArgumentError.checkNotNull(context, 'context');
_overrideForTesting = context;
}