Skip to content

Commit 3e356e6

Browse files
committed
Add MockCommand "run" terminology API (v9.3.0)
Migrates MockCommand to match Command v9.0.0 API terminology: - Add startRun(), endRunWithData(), endRunWithError(), endRunNoData() - Add queueResultsForNextRunCall() method - Add runCount, lastPassedValueToRun, returnValuesForNextRun properties - Deprecate all old "execute" terminology methods and properties - Add 8 comprehensive tests for new API - Update documentation (CHANGELOG, BREAKING_CHANGE_EXECUTE_TO_RUN.md) All deprecated APIs will be removed in v10.0.0. Migration guide available in BREAKING_CHANGE_EXECUTE_TO_RUN.md.
1 parent e72c64e commit 3e356e6

File tree

5 files changed

+421
-35
lines changed

5 files changed

+421
-35
lines changed

BREAKING_CHANGE_EXECUTE_TO_RUN.md

Lines changed: 120 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,76 @@ These are internal and don't affect public API:
129129

130130
---
131131

132+
## MockCommand API Update (v9.3.0)
133+
134+
**Status**: ✅ Implemented in v9.3.0 (January 2025)
135+
136+
MockCommand was updated to match the Command API terminology migration. All "execute" terminology in MockCommand has been renamed to "run" with the same deprecation pattern.
137+
138+
### MockCommand Methods
139+
140+
| Old API (Deprecated) | New API | Purpose |
141+
|---------------------|---------|---------|
142+
| `startExecution([TParam? param])` | `startRun([TParam? param])` | Start simulated command execution |
143+
| `endExecutionWithData(TResult data)` | `endRunWithData(TResult data)` | End execution with success data |
144+
| `endExecutionWithError(String message)` | `endRunWithError(String message)` | End execution with error |
145+
| `endExecutionNoData()` | `endRunNoData()` | End execution without data |
146+
| `queueResultsForNextExecuteCall(values)` | `queueResultsForNextRunCall(values)` | Queue results for next run |
147+
148+
### MockCommand Properties
149+
150+
| Old API (Deprecated) | New API | Purpose |
151+
|---------------------|---------|---------|
152+
| `executionCount` | `runCount` | Number of times command was called |
153+
| `lastPassedValueToExecute` | `lastPassedValueToRun` | Last parameter passed to command |
154+
| `returnValuesForNextExecute` | `returnValuesForNextRun` | Queued results for next call |
155+
156+
### Migration Example
157+
158+
**Before (deprecated):**
159+
```dart
160+
final mockCommand = MockCommand<String, String>(initialValue: '');
161+
162+
mockCommand.startExecution('test');
163+
mockCommand.endExecutionWithData('result');
164+
expect(mockCommand.executionCount, 1);
165+
expect(mockCommand.lastPassedValueToExecute, 'test');
166+
```
167+
168+
**After (v9.3.0+):**
169+
```dart
170+
final mockCommand = MockCommand<String, String>(initialValue: '');
171+
172+
mockCommand.startRun('test');
173+
mockCommand.endRunWithData('result');
174+
expect(mockCommand.runCount, 1);
175+
expect(mockCommand.lastPassedValueToRun, 'test');
176+
```
177+
178+
### Deprecation Notes
179+
180+
- All old "execute" terminology methods and properties still work with deprecation warnings
181+
- Will be removed in v10.0.0 (same timeline as Command API)
182+
- Automated search/replace patterns from the main migration guide work for MockCommand too
183+
- Both old and new APIs are fully tested for backward compatibility
184+
185+
---
186+
132187
## Impact Analysis
133188

134189
### Affected Code Locations
135190

136-
**Core Library (`lib/`):** ~140 occurrences
191+
**Core Library (`lib/`):** ~140 occurrences (v9.0.0) + 30 occurrences (v9.3.0 MockCommand)
137192
- `lib/command_it.dart` - Command base class (~30 occurrences)
138193
- `lib/async_command.dart` - Async implementation (~25 occurrences)
139194
- `lib/sync_command.dart` - Sync implementation (~20 occurrences)
140195
- `lib/undoable_command.dart` - Undoable implementation (~35 occurrences)
141-
- `lib/mock_command.dart` - Mock implementation (~15 occurrences)
196+
- `lib/mock_command.dart` - Mock implementation (~15 occurrences in v9.0.0, +30 in v9.3.0 for MockCommand-specific API)
142197
- `lib/command_builder.dart` - Widget builder (~10 occurrences)
143198
- `lib/code_for_docs.dart` - Documentation examples (~5 occurrences)
144199

145-
**Tests (`test/`):** ~56 occurrences
146-
- `test/flutter_command_test.dart` - Main test suite (~33 occurrences)
200+
**Tests (`test/`):** ~56 occurrences (v9.0.0) + 8 new tests (v9.3.0 MockCommand)
201+
- `test/flutter_command_test.dart` - Main test suite (~33 occurrences in v9.0.0, +8 new tests in v9.3.0 for MockCommand API)
147202
- `test/error_test.dart` - Error handling tests (~21 occurrences)
148203
- `test/callable_assignment_test.dart` - Callable class tests (~2 occurrences)
149204

@@ -209,14 +264,32 @@ isExecuting: → isRunning:
209264
.isExecuting → .isRunning
210265
```
211266

212-
**Step 2: Manual review**
267+
**Step 2: MockCommand migration (if using MockCommand)**
268+
269+
MockCommand users should also apply these replacements:
270+
271+
```
272+
# MockCommand methods
273+
.startExecution( → .startRun(
274+
.endExecutionWithData( → .endRunWithData(
275+
.endExecutionWithError( → .endRunWithError(
276+
.endExecutionNoData( → .endRunNoData(
277+
.queueResultsForNextExecuteCall( → .queueResultsForNextRunCall(
278+
279+
# MockCommand properties
280+
.executionCount → .runCount
281+
.lastPassedValueToExecute → .lastPassedValueToRun
282+
.returnValuesForNextExecute → .returnValuesForNextRun
283+
```
284+
285+
**Step 3: Manual review**
213286

214287
Check these edge cases:
215288
- String literals containing "execute" (e.g., log messages)
216289
- Comments and documentation
217290
- Variable names like `shouldExecute` → consider renaming
218291

219-
**Step 3: Test and verify**
292+
**Step 4: Test and verify**
220293

221294
```bash
222295
flutter analyze
@@ -432,6 +505,8 @@ for migration guide. (deprecated_member_use)
432505
| November 2025 | v8.0.3 | Document implicit call tear-off issue |
433506
| November 2025 | v8.1.0 | Hybrid error filtering + other features |
434507
| November 2025 | **v9.0.0** | **Add "run" API, deprecate "execute" API** |
508+
| November 2025 | v9.2.0 | CommandBuilder auto-run + Command.toWidget deprecation |
509+
| January 2025 | **v9.3.0** | **MockCommand "run" API migration** |
435510
| Nov 2025 - May 2026 | v9.x | Bug fixes, ecosystem migration period |
436511
| May-June 2026 | **v10.0.0** | **Remove deprecated "execute" API** |
437512

@@ -613,14 +688,52 @@ const CommandResult({
613688
- [ ] Verify backward compatibility (old code still works)
614689
- [ ] Update pub.dev package description
615690

691+
### Phase 1.5: v9.3.0 MockCommand Implementation
692+
693+
**MockCommand Library:**
694+
- [x] Add `startRun()` method alongside deprecated `startExecution()`
695+
- [x] Add `endRunWithData()` method alongside deprecated `endExecutionWithData()`
696+
- [x] Add `endRunWithError()` method alongside deprecated `endExecutionWithError()`
697+
- [x] Add `endRunNoData()` method alongside deprecated `endExecutionNoData()`
698+
- [x] Add `queueResultsForNextRunCall()` method alongside deprecated `queueResultsForNextExecuteCall()`
699+
- [x] Add `runCount` property alongside deprecated `executionCount`
700+
- [x] Add `lastPassedValueToRun` property alongside deprecated `lastPassedValueToExecute`
701+
- [x] Add `returnValuesForNextRun` property alongside deprecated `returnValuesForNextExecute`
702+
- [x] Add `@Deprecated` annotations to all old MockCommand APIs
703+
- [x] Update internal references to use new field names
704+
705+
**Tests:**
706+
- [x] Add 8 new tests for MockCommand "run" API
707+
- [x] Verify all existing MockCommand tests still pass with old API
708+
- [x] Test backward compatibility (both APIs work)
709+
710+
**Documentation:**
711+
- [x] Update BREAKING_CHANGE_EXECUTE_TO_RUN.md with MockCommand section
712+
- [x] Update CHANGELOG.md with v9.3.0 entry
713+
- [x] Update pubspec.yaml to v9.3.0
714+
- [ ] Update docs/testing.md with new MockCommand API examples
715+
- [ ] Update code samples to use new MockCommand API
716+
717+
**Quality:**
718+
- [x] Run MockCommand tests
719+
- [x] Verify compilation (no errors)
720+
- [x] Format code with dart format
721+
616722
### Phase 2: v10.0.0 Implementation
617723

724+
**Command API Removal:**
618725
- [ ] Remove all `@Deprecated` execute* methods
619726
- [ ] Remove all `@Deprecated` isExecuting/canExecute properties
620727
- [ ] Remove deprecated CommandResult.isExecuting getter
621728
- [ ] Remove deprecated parameter names
729+
730+
**MockCommand API Removal:**
731+
- [ ] Remove all `@Deprecated` MockCommand execute* methods (startExecution, endExecutionWithData, etc.)
732+
- [ ] Remove all `@Deprecated` MockCommand properties (executionCount, lastPassedValueToExecute, returnValuesForNextExecute)
733+
734+
**Final Steps:**
622735
- [ ] Update CHANGELOG with final breaking change notice
623-
- [ ] Verify no references to old API remain
736+
- [ ] Verify no references to old API remain (including MockCommand)
624737
- [ ] Run full test suite
625738
- [ ] Update semantic version to 10.0.0
626739

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
[9.3.0] - 2025-01-23
2+
3+
### Added
4+
5+
- **MockCommand "run" Terminology**: MockCommand now uses "run" terminology to match the Command API migration from v9.0.0:
6+
- `startRun()` - replaces `startExecution()`
7+
- `endRunWithData()` - replaces `endExecutionWithData()`
8+
- `endRunWithError()` - replaces `endExecutionWithError()`
9+
- `endRunNoData()` - replaces `endExecutionNoData()`
10+
- `queueResultsForNextRunCall()` - replaces `queueResultsForNextExecuteCall()`
11+
- `runCount` property - replaces `executionCount`
12+
- `lastPassedValueToRun` property - replaces `lastPassedValueToExecute`
13+
- `returnValuesForNextRun` property - replaces `returnValuesForNextExecute`
14+
15+
### Deprecated
16+
17+
- **Old MockCommand "execute" Terminology**: All "execute" terminology methods and properties in MockCommand are now deprecated
18+
- Will be removed in v10.0.0
19+
- See `BREAKING_CHANGE_EXECUTE_TO_RUN.md` for migration guide
20+
121
[9.2.0] - 2025-11-22
222

323
### New Features

0 commit comments

Comments
 (0)