Contents

EvaluationTrait

A test trait that runs an evaluation and records the result as attachments.

Declaration

struct EvaluationTrait

Mentioned in

Overview

let accuracyMetric = Metric("Accuracy")

@Test(.evaluates(myEvaluation))
func testAccuracy() async throws {
    let result = EvaluationContext.current.result
    #expect(result.aggregateValue(.mean(of: accuracyMetric)) >= 0.8)
}

The result is accessible from an evaluation context.

Topics

Instance Methods

See Also

Swift Testing integration