FakeCommandExec class

Lightweight configurable CommandExec fake for service tests.

Dispatches each run call to handler (keyed on command + arguments) and records every invocation so tests can assert on what was executed.

Implemented types

Constructors

FakeCommandExec(CommandResult? handler(String command, List<String> arguments))
Creates a fake that consults handler for each run.

Properties

calls → List<FakeCommandCall>
Recorded run invocations, in order.
final
handler ↔ CommandResult? Function(String command, List<String> arguments)
Returns a result for a given command + arguments, or null to fall back to a default failing result.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(String command, {List<String> arguments = const [], String? workingDirectory, Duration? timeout}) → Future<CommandResult>
Runs command with arguments and returns stdout/stderr/exit code.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fail([String stderr = '', String stdout = '', int exitCode = 1]) → CommandResult
Failing result helper.
ok([String stdout = '', String stderr = '']) → CommandResult
Successful result helper (exitCode 0).