D4rtTester class

Runs D4rt scripts and evaluations with in-memory bridge generation and subprocess-based test execution.

The test flow is:

  1. Bridge generation — runs the bridge generator in-memory (same process) to produce bridge files and a test runner in projectPath.
  2. Subprocess execution — spawns dart run bin/<runner>.dart --test in the project directory. The generated test runner registers all bridges, executes the D4rt script inside runZonedGuarded with a ZoneSpecification to capture print() output and unhandled exceptions, then emits structured JSON.
  3. 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 null if generation was successful.
no setter
projectPath String
Path to the project directory.
final
runnerExecutable String
The test runner filename (without .dart extension).
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