Skip to content

[tool] TestBed doesn't include a stub for Analytics #150663

@andrewkolos

Description

@andrewkolos

Discovered while working on #150575

See

// A default value should be provided if the vast majority of tests should use
// this provider. For example, [BufferLogger], [MemoryFileSystem].
final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
// Keeps tests fast by avoiding the actual file system.
FileSystem: () => MemoryFileSystem(style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix),
ProcessManager: () => FakeProcessManager.any(),
Logger: () => BufferLogger(
terminal: AnsiTerminal(stdio: globals.stdio, platform: globals.platform), // Danger, using real stdio.
outputPreferences: OutputPreferences.test(),
), // Allows reading logs and prevents stdout.
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
OutputPreferences: () => OutputPreferences.test(), // configures BufferLogger to avoid color codes.
Usage: () => TestUsage(), // prevent addition of analytics from burdening test mocks
FlutterVersion: () => FakeFlutterVersion(), // prevent requirement to mock git for test runner.
Signals: () => FakeSignals(), // prevent registering actual signal handlers.
Pub: () => ThrowingPub(), // prevent accidental invocations of pub.
};

TestBed isn't a construct used too often in tool tests in nowadays, but I noticed it includes a stub for Usage, but not for Analytics (from package:unified_analytics). Usage is deprecated, the backend is offline (to my knowledge), and has been replaced by Analytics (see #128251).

This context-injected stub of Usage should probably be replaced with one for Analytics, otherwise, tests using TestBed might be sending analytics events.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions