D4rtTester class
Runs D4rt scripts and evaluations with in-memory bridge generation and subprocess-based test execution.
The test flow is:
- Bridge generation — runs the bridge generator in-memory (same process) to produce bridge files and a test runner in projectPath.
- Subprocess execution — spawns
dart run bin/<runner>.dart --testin the project directory. The generated test runner registers all bridges, executes the D4rt script insiderunZonedGuardedwith aZoneSpecificationto captureprint()output and unhandled exceptions, then emits structured JSON. - Result parsing — parses the JSON output into a D4rtTestResult with timeout detection.
This class is designed for use in the bridge generator's own tests, where bridge generation and execution must both be verified end-to-end.
Constructors
- D4rtTester({required String projectPath, Duration defaultTimeout = const Duration(seconds: 3), String runnerExecutable = 'd4rtrun.b', String compiledBinaryName = 'd4'})
Properties
- compiledBinaryName → String
-
The compiled binary name (without path).
final
- defaultTimeout → Duration
-
Default timeout for test execution.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
lastGenerationErrors
→ List<
String> ? -
Public accessor for errors from the last prepareBridges call.
Returns
nullif generation was successful.no setter - projectPath → String
-
Path to the project directory.
final
- runnerExecutable → String
-
The test runner filename (without
.dartextension).final - 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
-
prepareBridges(
BridgeConfig config) → Future< bool> - Generate bridges once for a project without running any script.
-
runEval(
BridgeConfig config, String initScriptFile, String expressionFile, {Duration? timeout}) → Future< D4rtTestResult> - Generate bridges and evaluate an expression file, capturing results.
-
runScript(
BridgeConfig config, String scriptFile, {Duration? timeout}) → Future< D4rtTestResult> - Generate bridges and run a D4rt script file, capturing results.
-
runScriptOnly(
BridgeConfig config, String scriptFile, {Duration? timeout}) → Future< D4rtTestResult> - Run a D4rt script file without regenerating bridges.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited