Skip to main content

Module testkit

Module testkit 

Source
Expand description

Testkit — Conformance adapter runner.

Provides a reusable framework for running conformance vectors against any SDK implementation. New SDKs implement the AshAdapter trait and get full conformance testing for free.

§Usage

  1. Implement AshAdapter for your SDK
  2. Call load_vectors() to parse vectors.json
  3. Call run_vectors() to execute all vectors
  4. Inspect the TestReport for pass/fail + diffs

§Example

use ash_core::testkit::{load_vectors, run_vectors, AshAdapter, AdapterResult};

struct MyAdapter;
impl AshAdapter for MyAdapter {
    fn canonicalize_json(&self, input: &str) -> AdapterResult {
        match my_sdk::canonicalize(input) {
            Ok(s) => AdapterResult::ok(s),
            Err(e) => AdapterResult::error(e.code, e.status),
        }
    }
    // ... implement other methods
}

let vectors = load_vectors(include_bytes!("../../tests/conformance/vectors.json")).unwrap();
let report = run_vectors(&vectors, &MyAdapter);
assert!(report.all_passed(), "Failures: {:?}", report.failures());

Structs§

AdapterResult
Result from an adapter operation.
TestReport
Report from running all vectors.
Vector
A single conformance vector.
VectorFile
Top-level vectors file.
VectorResult
Result of running a single vector.

Traits§

AshAdapter
Trait that SDK implementations must implement for conformance testing.

Functions§

load_vectors
Load vectors from raw JSON bytes (e.g., include_bytes!).
load_vectors_from_file
Load vectors from a file path.
run_vectors
Run all vectors against an adapter.