Repository navigation
flutter_tools/test/src/context.dart has non-mock "Mock*" classes #33274
Copy link
Copy link
Closed
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: contributor-productivityTeam-specific productivity, code health, technical debt.Team-specific productivity, code health, technical debt.team-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.Issues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Description
No activity
Activity on this issue will appear here.
Activity
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: contributor-productivityTeam-specific productivity, code health, technical debt.Team-specific productivity, code health, technical debt.team-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.Issues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
There are various classes in context.dart that are called
Mock*but are not actually mocks. It seems random, and possibly just an oversight. For instance:class MockXcodeProjectInterpreter implements XcodeProjectInterpreterbut
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtilsThis is bug number 1.
It looks like they are intended for use in the default
testUsingContext, but are public (I would argue that being public is bug number 2).Taking the
MockXcodeProjectInterpreterexample, test files that actually want to mock that class have:class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterpreter {}This shadows the version in context.dart (bug number 3).
When you put all this together, you end up with the very surprising behavior that if you take a working test using a local
MockXcodeProjectInterpreterand move it to a new file, but neglect to add a local override in that new file, everything compiles just fine and you get mysteriousMock method was not called within 'when()'errors and waste a lot of time trying to figure out what's going on.I would argue that at a minimum
Mock*need to beMockobjects.