TestHarness class
Bundles the three in-memory exporters and the on-demand metric
reader so tests have one handle to clear() between cases.
Construct via maybeInitializeOtelForTest.
Constructors
- TestHarness({required InMemorySpanExporter spans, required InMemoryLogExporter logs, required InMemoryMetricExporter metrics, required MetricReader metricReader})
- Creates a harness. Prefer maybeInitializeOtelForTest over calling this directly.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- logs → InMemoryLogExporter
-
The log exporter that received every emitted log record.
final
- metricReader → MetricReader
-
The reader driving metric collection.
final
- metrics → InMemoryMetricExporter
-
The metric exporter that received every emitted metric snapshot.
New snapshots arrive only when you call collectMetrics.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spans → InMemorySpanExporter
-
The span exporter that received every emitted span.
final
Methods
-
clear(
) → void -
Resets all three exporters' buffers. Call from
setUp(). -
collectMetrics(
) → Future< void> - Pumps the meter provider and forwards collected metrics to the in-memory exporter. Call this in a test after recording metrics but before asserting on metrics.
-
flushLogs(
) → Future< void> - Forces the SDK's logger pipeline to flush. Tests that emit logs synchronously usually don't need this, but it's safe to call.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited