Library Moduleswift-metrics 2.6.1MetricsTestKit

MetricsTestKit

A set of tools for testing Metrics emitting libraries.

index.md
import MetricsTestKit

Module information

Declarations
88
Symbols
96

Coverage

6.8 percent of the declarations in MetricsTestKit are fully documented55.7 percent of the declarations in MetricsTestKit are indirectly documented37.5 percent of the declarations in MetricsTestKit are completely undocumented

Declarations

5.7 percent of the declarations in MetricsTestKit are operators3.4 percent of the declarations in MetricsTestKit are initializers, type members, or enum cases75.0 percent of the declarations in MetricsTestKit are instance members1.1 percent of the declarations in MetricsTestKit are protocols4.5 percent of the declarations in MetricsTestKit are protocol requirements2.3 percent of the declarations in MetricsTestKit are structures5.7 percent of the declarations in MetricsTestKit are classes2.3 percent of the declarations in MetricsTestKit are typealiases

Interfaces

100.0 percent of the declarations in MetricsTestKit are unrestricted
Module stats and coverage details

Overview

This module offers a TestMetrics type which can be used to bootstrap the metrics system and then assert metric values on it.

Example

import XCTest
import Metrics
import MetricsTestKit

final class ExampleTests: XCTestCase {
    var metrics: TestMetrics! = TestMetrics()

    override func setUp() {
        MetricsSystem.bootstrapInternal(self.metrics)
    }

    override func tearDown() async throws {
        self.metrics = nil
        MetricsSystem.bootstrapInternal(NOOPMetricsHandler.instance)
    }

    func test_example() async throws {
        // Create a metric using the bootstrapped test metrics backend:
        Recorder(label: "example").record(100)
        
        // extract the `TestRecorder` out of the 
        let recorder = try self.metrics.expectRecorder("example")
        recorder.lastValue?.shouldEqual(6)
    }
}

Test metrics