JustDummies

Just dummies — but seriously powerful ones.

API v1.0.0-preview.6 · JustDummies.Xunit v1.0.0-preview.2

API sections

Seeds & reproducibility

What makes a failure on an arbitrary value replayable exactly, instead of a mystery that looks different on every run.

sealed class

[Reproducible]

Makes a test's arbitrary values reproducible: the ambient Any context is pinned to a seed for the duration of the test, and that seed is reported only when the test fails — so a red test names the exact seed to replay while a green one stays silent. This is the declarative form of Any.Reproducibly(() => { ... }): the values still vary between runs, which is what surfaces a test secretly depending on one, but a failure is recoverable without the body having been wrapped in advance.

public sealed class ReproducibleAttribute
Extends
BeforeAfterTestAttribute
Implements
IBeforeAfterTestAttribute

Constructors

ReproducibleAttribute()

Properties

int Seed { get; set; }The seed to pin, to replay a run a previous failure reported. Left unset, every test case draws a fresh seed — the arbitrary-by-default behaviour that surfaces a test depending on one particular value.

Methods

void Before(MethodInfo methodUnderTest, IXunitTest test)
void After(MethodInfo methodUnderTest, IXunitTest test)

static method

Reproducibly

Runs body with the ambient random context pinned to a fresh seed and, if the body throws, reports that seed before letting the exception propagate. This is how a test that draws on Any stays reproducible: the values still vary between runs (which surfaces accidental dependencies), yet a failure names the exact seed to replay.

static void Any.Reproducibly(Action body, Action<string>? report = null)

Methods

static void Any.Reproducibly(Action body, Action<string>? report = null)Runs body with the ambient random context pinned to a fresh seed and, if the body throws, reports that seed before letting the exception propagate. This is how a test that draws on Any stays reproducible: the values still vary between runs (which surfaces accidental dependencies), yet a failure names the exact seed to replay.
static void Any.Reproducibly(int seed, Action body, Action<string>? report = null)Replays body with the ambient random context pinned to seed, so a run first seen through the parameterless Reproducibly overload can be reproduced exactly. If the body throws, the seed is reported before the exception propagates.

static method

ReproduciblyAsync

Asynchronous counterpart of Reproducibly: awaits body under a fresh seed and reports it if the body faults.

static Task Any.ReproduciblyAsync(Func<Task> body, Action<string>? report = null)

Methods

static Task Any.ReproduciblyAsync(Func<Task> body, Action<string>? report = null)Asynchronous counterpart of Reproducibly: awaits body under a fresh seed and reports it if the body faults.
static Task Any.ReproduciblyAsync(int seed, Func<Task> body, Action<string>? report = null)Asynchronous counterpart of Reproducibly: awaits body under seed and reports it if the body faults.

static method

UseSeed

Pins the ambient random context to seed until the returned handle is disposed — the scope form of Reproducibly, for a caller that cannot wrap the code it pins in a delegate. A test-framework adapter is the case this exists for: it observes a test through hooks that run before and after it, so it opens the scope in one and disposes it in the other.

static IDisposable Any.UseSeed(int seed)

Methods

static IDisposable Any.UseSeed(int seed)Pins the ambient random context to seed until the returned handle is disposed — the scope form of Reproducibly, for a caller that cannot wrap the code it pins in a delegate. A test-framework adapter is the case this exists for: it observes a test through hooks that run before and after it, so it opens the scope in one and disposes it in the other.
static IDisposable Any.UseSeed(int seed, string replaySnippet)Pins the ambient random context to seed and supplies the replay snippet — the code a reader copies to replay this run — that generation-failure guidance will embed. This is the form a test-framework adapter uses: the default snippet is Any.Reproducibly(seed, ...), which points at a call a test pinned from outside its own body does not contain, where replaying means changing what the adapter reads instead.