Namespace Hegel
Classes
- ArrayGenerator<T>
Draws arrays of values from an element generator.
- BigIntegerGenerator
Draws integers of any size, in a range or around ±2^127 when unbounded.
- BinaryGenerator
Draws byte arrays.
- ConcurrentPool<T>
A Pool<T> shared by the workers of a concurrent stateful test.
- Database
Where a run keeps the failures it finds, to replay them first next time: the engine's default location, a directory of your choosing, or nowhere.
- Deferred<T>
A generator defined after it is referred to, for recursive definitions.
- Dialect
The language a failing test case's draws are printed in: how the statement binding a draw is written, and how Repr(object?, Type) prints a value. C# unless another frontend, such as Hegel for F#, installs its own with Use(Dialect) around a run.
- DidNotReproduceException
Thrown by a ReproduceFailure run none of whose blobs reproduced a failure: the failure may have been fixed, or a nondeterministic one may not have recurred.
- Document
A Printer of your own, outside any test case: print to Printer and read the laid-out text with Finish().
- DomainGenerator
Draws domain names.
- DoubleGenerator
Draws 64-bit floating-point numbers.
- Example
An explicit test case: the values its draws return, positionally and by draw label, run before the generated ones when Examples holds it.
- Failure
One distinct failure a run found, with the minimal test case that shows it.
- FilteredGenerator<T>
A generator that draws from another until a predicate accepts the value.
- FlakyTestException
Thrown when, under Error, the test produced different outcomes, or drew different data, when replayed on identical choices.
- FlatMappedGenerator<TSource, TResult>
A generator that draws a value and then from the generator chosen for it.
- FloatGenerator
Draws 32-bit floating-point numbers.
- Generator<T>
Draws values of
Tfrom a TestCase. Implement DoDraw(TestCase) for a generator that draws through other generators or the engine primitives, or derive from PrintableGenerator<T> to print as you draw. Built-in generators are in Generators.
- Generators
The built-in generators. Each returns a generator you can narrow with its methods (
Generators.Integers().Min(0),Generators.Lists(g).MaxSize(5)) or combine with Map<TResult>(Func<T, TResult>), Filter(Func<T, bool>) and FlatMap<TResult>(Func<T, Generator<TResult>>).
- Generators.Temporal
The date and time generators, under the names every Hegel frontend shares. The values they draw, and ZoneSource, are in the Hegel.Temporal namespace.
- GrammarHandle
A handle to a compiled engine grammar, freed with the handle.
- HealthCheckFailure
Thrown when the engine aborts a run because a HealthCheck fired: the test itself is misbehaving (rejecting almost every input, or generating data that is too large or too slow) rather than the property being false. If the behaviour is intentional, disable the offending check with SuppressHealthCheck.
- HegelException
Thrown for engine, configuration and binding errors: anything that is not a property failure.
A failing property rethrows the test body's own exception, so it integrates with any test framework; this exception signals that something went wrong with Hegel itself (a missing engine library, an internal engine error). HegelRunException and its subtypes are raised when the engine aborts a run (a failed health check, a flaky or unsatisfiable test), and DidNotReproduceException when no replayed failure blob fails.
- HegelInfrastructureAttribute
Marks an assembly as part of Hegel rather than of the test under it: a failure's origin skips its frames, as it skips the test framework's. Hegel's own frontends carry it; a library of generators or a test-framework integration built on Hegel may too.
- HegelRunException
Thrown when the engine aborts a run with an error rather than a verdict on the property. ErrorKind classifies it, and the subtypes HealthCheckFailure, FlakyTestException and UnsatisfiableException name the common kinds.
- HegelUsageException
Thrown for a usage error the engine or the frontend detects while a test runs: an argument the engine rejects (such as an unknown text codec), a draw from a generator that cannot print, or a test-case handle used after its stateful rule ended. It aborts the run rather than counting as a failure of the property.
- IntegerGenerator
Draws 32-bit integers in a range.
- InvalidExampleException
Thrown for a misuse of an explicit Example: a draw it has no value for, a value it has that no draw takes, or a test-case operation an explicit test case cannot perform.
- InvariantAttribute
Marks a method of a state machine as an invariant, checked between steps. It takes one TestCase parameter.
- IpAddressGenerator
Draws IP addresses as text: a mix of IPv4 and IPv6 unless narrowed.
- Label
Span labels: how the engine tells one kind of draw from another when it shrinks. A generator's Label is one of these, Of(string) a name, or a Combine(params ulong[])d label.
- LarkGenerator
Draws strings from a grammar in Lark syntax.
- ListGenerator<T>
Draws lists of values from an element generator.
- LongGenerator
Draws 64-bit integers in a range.
- MapGenerator<TKey, TValue>
Draws dictionaries from key and value generators.
- MappedGenerator<TSource, TResult>
A generator whose values are another's, transformed by a function.
- MultipleFailuresException
Thrown by Test(Action<TestCase>, Settings?, Reporter?, string, int, string) when a run reports several distinct failures: the message lists them and Failures carries each failure's own exception.
- Pool<T>
Values a stateful test has created, for later rules to draw from: the engine chooses which, and shrinks towards fewer and earlier values. One pool belongs to one test case.
- PrintableGenerator<T>
A Generator<T> that prints each value as it draws it, so a failing test case's draws can be shown as the code that rebuilds them. Only printable generators can be drawn with Draw<T>(Generator<T>, string?).
- PrintedGenerator<T>
A generator printing another's values with a function of your own.
- Printer
Prints a drawn value as the engine lays it out: text, groups that break across lines when they run past the width, and comments. A PrintableGenerator<T> prints through one as it draws; outside a draw, Document gives you one.
- Printer.Speculation
A speculative region of a Printer's output: kept on Commit(), discarded otherwise.
- Property
Entry points: Test(Action<TestCase>, Settings?, Reporter?, string, int, string) runs a property and throws on failure, as a test method wants; Run(Action<TestCase>, Settings?, Reporter?, string, int, string) returns the RunReport instead.
[Fact] public void Addition_commutes() => Property.Test(tc => { var a = tc.Draw(Generators.Integers()); var b = tc.Draw(Generators.Integers()); Assert.Equal(a + b, b + a); });
- RecordGenerator<T>
Draws records by drawing each component: the primary constructor's parameters, then the settable properties it leaves out. Printed as
new Name(a, b), with{ X = c }after it for the properties.
- RecursiveGenerator<T>
Draws recursive structures: a base case, extended by a function a bounded number of times.
- RegexGenerator
Draws strings matching a regular expression.
- Reporter
Receives what a run reports as it happens. Override what you want to hear about; the default implementations do nothing. Printing(TextWriter) writes the standard report to a writer and Silent discards it.
- RuleAttribute
Marks a method of a state machine as a rule: a step the test may take. It takes one TestCase parameter.
- RunReport
What a run found: its status, statistics, failures and any error that stopped it.
- RunStatistics
How many test cases a run executed, by outcome.
- SampleGenerator<T>
Draws samples of a sequence: some of its elements in any order, with or without replacement.
- SetGenerator<T>
Draws sets of distinct values from an element generator.
- Settings
How a test runs. A new
Settingsholds the engine's resolved defaults (thehegel.tomlprofile and theHEGEL_*environment variables), so what you read back is what the run uses; set properties with an object initializer or awithexpression:var settings = new Settings { TestCases = 500, Seed = 42 }; var ci = Settings.FromProfile("ci") with { Verbosity = Verbosity.Verbose };
- Stateful
Stateful testing: drive an object whose RuleAttribute methods are the steps the test may take and whose InvariantAttribute methods must hold between them.
- StatefulOptions
How Run(object, TestCase, StatefulOptions) drives a state machine.
- StringGeneratorHandle
A handle to an engine string generator (text, regex, email, URL or domain), freed with the handle.
- SubsequenceGenerator<T>
Draws subsequences of a sequence: its elements in order, some left out.
- TestCase
One run of the test body: draw values from generators, make assumptions, add notes. The engine chooses what each draw returns, records the draws of a failing run and shrinks them to the smallest failing test case, which is printed as the C# that rebuilds it.
- TestLocation
Where a test is defined, as reported to the engine (and through it to Antithesis): the source file, the line it begins on, the enclosing class and the method.
- TextGenerator
Draws strings: any Unicode text by default, narrowed by size, code point, category or alphabet.
- UnsatisfiableException
Thrown when no valid test case was ever generated: every input was rejected.
- UuidGenerator
Draws UUIDs, of any version or one in particular.
- ValueGenerator<T>
A printable generator that prints its values with Repr(object?).
Enums
- Backend
Where the engine's randomness comes from.
- CaseOutcome
How one test case ended.
- HealthCheck
The engine's health checks; SuppressHealthCheck is a set of them.
- NondeterminismStrictness
What the engine does when a test turns out to be nondeterministic.
- RunErrorKind
Why a run ended in Error.
- RunStatus
How a run ended.
- Verbosity
How much a run reports: the engine's verbosity setting.