test_process
2.1.1, released 2 years ago by tools.dart.dev
Utility for testing subprocesses with line‑by‑line stdout/stderr streams.
Quiet but busy
What it does
Provides a TestProcess class that wraps dart:io Process for easier testing. It offers line‑oriented stdout/stderr streams via StreamQueue and helpers like shouldExit and debugging output.
AI-written summary of version 2.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to run and verify CLI tools or other subprocesses in unit tests.
- You want line‑by‑line assertions on stdout/stderr using the test package's stream matchers.
Skip it when
- You are writing production code that launches processes.
- You need full control over signals on Windows (unsupported).
Strengths
- Line‑by‑line stdout/stderr streams simplify assertions.
- Built‑in integration with the test package’s stream matchers.
- Debugging output automatically shows process logs on failure.
Weaknesses
- Only intended for testing, not for runtime process management.
- Limited signal support on Windows.
- Requires Dart 3.1, so older SDKs cannot use it.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:test/test.dart';
import 'package:test_process/test_process.dart';
void main() {
test('pub get gets dependencies', () async {
var process = await TestProcess.start('dart', ['pub', 'get']);
await expectLater(process.stdout, emits('Resolving dependencies...'));
await expectLater(process.stdout, emitsThrough('Got dependencies!'));
await process.shouldExit(0);
});
}Alternatives
Packages that do the same job and could replace test_process.
Works with
Packages commonly used together with test_process: ones it builds on, ones built on it, and its own family.
- asynctest_process depends on itUtility classes and helpers that extend Dart's async library.
- testtest_process depends on itA full featured library for writing and running Dart tests across platforms.
- test_apiSame familyThe user facing API for structuring Dart tests and checking expectations.
- test_descriptorSame familyDeclarative API for creating and verifying file and directory structures in tests.
- test_reflective_loaderSame familyRuns test suites and methods discovered via reflection.
- cli_pkgBuilt on test_processGrinder tasks for releasing Dart CLI packages.