Apply mocks to test command#42118
Conversation
| test('Builds a web bundle - end to end', () => testbed.run(() async { | ||
| final CommandRunner<void> runner = createTestCommandRunner(BuildCommand()); | ||
| final BuildCommand buildCommand = BuildCommand(); | ||
| applyMocksToCommand(buildCommand); |
There was a problem hiding this comment.
Is there any situation where we wouldn't want to do this? Is it possible to add an assert to createTestCommandRunner() to check that the mocks have been applied? If there are any, in the cases where mocks shouldn't be supplied, maybe we should have a call separate from createTestCommandRunner() that doesn't have the asserts.
There was a problem hiding this comment.
Basically, "How do we make this less error prone?"
There was a problem hiding this comment.
I think the best way would be to create a testbed specific command runner and enforce using that via import checks. For integration tests, I imagine we still want the capability to invoke commands directly
Codecov Report
@@ Coverage Diff @@
## master #42118 +/- ##
==========================================
+ Coverage 59.67% 59.72% +0.04%
==========================================
Files 194 194
Lines 18977 18977
==========================================
+ Hits 11325 11334 +9
+ Misses 7652 7643 -9
Continue to review full report at Codecov.
|
Description
Missed the call to applyMocks. This causes several pieces of real functionality like pub to be run during the test, making it significantly more flaky than it needs to be.