Class HegelTestAttribute
Marks an xUnit test method as a Hegel property. The method takes one TestCase
and returns void; the engine runs it many times with generated inputs, shrinks any
failure to a minimal counterexample, puts the counterexample in the test's output and fails
the test with the assertion itself, as Test(Action<TestCase>, Settings?, Reporter?, string, int, string) does:
[HegelTest]
public void Addition_commutes(TestCase tc)
{
var a = tc.Draw(Generators.Integers());
var b = tc.Draw(Generators.Integers());
Assert.Equal(a + b, b + a);
}
The property is one test in xUnit's test tree. Profile and TestCases
adjust its settings; for any other setting, or one only known at runtime, call
Test(Action<TestCase>, Settings?, Reporter?, string, int, string) from a [Fact] instead.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("Hegel.Xunit.HegelTestDiscoverer", "Hegel.Xunit")]
public sealed class HegelTestAttribute : FactAttribute
- Inheritance
-
FactAttributeHegelTestAttribute
- Inherited Members
-
FactAttribute.DisplayNameFactAttribute.SkipFactAttribute.Timeout
Constructors
HegelTestAttribute(string, int)
Marks the method as a Hegel property. The parameters are filled in by the compiler with where the attribute is written, which is the test's location for the database and Antithesis.
public HegelTestAttribute(string sourceFile = "", int sourceLine = 0)
Parameters
Properties
Profile
The hegel.toml profile (or one registered with RegisterProfile(string, Settings))
the test's settings resolve from, instead of the default profile.
public string? Profile { get; set; }
Property Value
SourceFile
The source file the attribute is written in.
public string SourceFile { get; }
Property Value
SourceLine
The line the attribute is written on.
public int SourceLine { get; }
Property Value
TestCases
How many test cases to generate. 0, the default, leaves the number to the settings
profile and the HEGEL_TEST_CASES environment variable.
public long TestCases { get; set; }