TestProcess class Null safety

A wrapper for Process that provides a convenient API for testing its standard IO and interacting with it from a test.

If the test fails, this will automatically print out any stdout and stderr from the process to aid debugging.

This may be extended to provide custom implementations of stdoutStream and stderrStream. These will automatically be picked up by the stdout and stderr queues, but the debug log will still contain the original output.


TestProcess(Process process, String description, {Encoding encoding = utf8, bool forwardStdio = false})
Creates a TestProcess for process. [...]


description String
A human-friendly description of this process.
exitCode Future<int>
Returns a Future which completes to the exit code of the process, once it completes.
hashCode int
The hash code for this object. [...]
read-only, inherited
pid int
The process ID of the process.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
stderr StreamQueue<String>
A StreamQueue that emits each line of stderr from the process. [...]
final, late
stdin IOSink
The standard input sink for this process.
stdout StreamQueue<String>
A StreamQueue that emits each line of stdout from the process. [...]
final, late


kill() Future
Kills the process (with SIGKILL on POSIX operating systems), and returns a future that completes once it's dead. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
shouldExit([dynamic expectedExitCode]) Future
Waits for the process to exit, and verifies that the exit code matches expectedExitCode (if given). [...]
signal(ProcessSignal signal) → void
Sends signal to the process. [...]
stderrStream() Stream<String>
Returns a copy of stderr as a single-subscriber stream. [...]
stdoutStream() Stream<String>
Returns a copy of stdout as a single-subscriber stream. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Methods

start(String executable, Iterable<String> arguments, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, String? description, Encoding encoding = utf8, bool forwardStdio = false}) Future<TestProcess>
Starts a process. [...]