Header menu logo testify

Check Type

Property-style runner that returns a structured CheckResult.

Static members

Static member Description

Check.assertPassed result

Full Usage: Check.assertPassed result

Parameters:
    result : CheckResult<'Args, 'Actual, 'Expected> - The property result to validate.

Raises when the supplied property result is not Passed.

result : CheckResult<'Args, 'Actual, 'Expected>

The property result to validate.

Exception Raised when result is Failed, Exhausted, or Errored.

Check.result (expectation, reference, actual, ?config, ?arbitrary)

Full Usage: Check.result (expectation, reference, actual, ?config, ?arbitrary)

Parameters:
    expectation : CheckExpectation<'Args, 'Actual, 'Expected> - The relation that should hold between tested code and the reference.
    reference : 'Args -> 'Expected - The trusted reference implementation. It receives the generated argument value and produces the expected outcome for comparison.
    actual : Expr<('Args -> 'Actual)> - The quoted tested function under evaluation.
    ?config : Config - Optional FsCheck configuration override. When omitted, Testify starts from the default configuration installed through Testify.currentConfiguration() and related configuration helpers. Common sources are CheckConfig.defaultConfig, CheckConfig.thorough, CheckConfig.withMaxTest, CheckConfig.withEndSize, and CheckConfig.withReplay.
    ?arbitrary : Arbitrary<'Args> - Optional custom arbitrary used to generate and shrink 'Args. When omitted, Testify resolves the default arbitrary for 'Args from the effective FsCheck configuration. Common sources are Arbitraries.from<'T>, Arbitraries.fromGen, Arbitraries.tuple2, Arbitraries.tuple3, and custom mapped/filter arbitraries.

Returns: CheckResult<'Args, 'Actual, 'Expected> Passed, Failed, Exhausted, or Errored depending on the FsCheck run and the observed tested/reference behavior.

Runs a property-style check against a reference implementation and returns the structured result.

Use result when you want to inspect or render failures yourself. Use should for the fail-fast twin.

expectation : CheckExpectation<'Args, 'Actual, 'Expected>

The relation that should hold between tested code and the reference.

reference : 'Args -> 'Expected

The trusted reference implementation. It receives the generated argument value and produces the expected outcome for comparison.

actual : Expr<('Args -> 'Actual)>

The quoted tested function under evaluation.

?config : Config

Optional FsCheck configuration override. When omitted, Testify starts from the default configuration installed through Testify.currentConfiguration() and related configuration helpers. Common sources are CheckConfig.defaultConfig, CheckConfig.thorough, CheckConfig.withMaxTest, CheckConfig.withEndSize, and CheckConfig.withReplay.

?arbitrary : Arbitrary<'Args>

Optional custom arbitrary used to generate and shrink 'Args. When omitted, Testify resolves the default arbitrary for 'Args from the effective FsCheck configuration. Common sources are Arbitraries.from<'T>, Arbitraries.fromGen, Arbitraries.tuple2, Arbitraries.tuple3, and custom mapped/filter arbitraries.

Returns: CheckResult<'Args, 'Actual, 'Expected>

Passed, Failed, Exhausted, or Errored depending on the FsCheck run and the observed tested/reference behavior.

Example

 let result =
     Check.result(
         CheckExpectation.equalToReference,
         List.rev,
         <@ List.rev @>)
val result: obj
Multiple items
module List from Microsoft.FSharp.Collections

--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T with get member IsEmpty: bool with get member Item: index: int -> 'T with get ...
val rev: list: 'T list -> 'T list

Check.resultBy (buildProperty, expectation, reference, actual, ?config)

Full Usage: Check.resultBy (buildProperty, expectation, reference, actual, ?config)

Parameters:
    buildProperty : ('Args -> bool) -> Property - A callback that receives the Testify verifier and must build an FsCheck property around it. Use this for nested or dependent quantification that is awkward to express with one plain Arbitrary<'Args>.
    expectation : CheckExpectation<'Args, 'Actual, 'Expected> - The relation that should hold between tested code and the reference.
    reference : 'Args -> 'Expected - The trusted reference implementation.
    actual : Expr<('Args -> 'Actual)> - The quoted tested function under evaluation.
    ?config : Config - Optional FsCheck configuration override. resultBy intentionally does not accept an arbitrary parameter because the custom property builder owns quantification.

Returns: CheckResult<'Args, 'Actual, 'Expected> Passed, Failed, Exhausted, or Errored depending on the property run.

Runs an advanced property-style check where the caller controls the surrounding FsCheck property structure and Testify supplies the per-case verifier.

buildProperty : ('Args -> bool) -> Property

A callback that receives the Testify verifier and must build an FsCheck property around it. Use this for nested or dependent quantification that is awkward to express with one plain Arbitrary<'Args>.

expectation : CheckExpectation<'Args, 'Actual, 'Expected>

The relation that should hold between tested code and the reference.

reference : 'Args -> 'Expected

The trusted reference implementation.

actual : Expr<('Args -> 'Actual)>

The quoted tested function under evaluation.

?config : Config

Optional FsCheck configuration override. resultBy intentionally does not accept an arbitrary parameter because the custom property builder owns quantification.

Returns: CheckResult<'Args, 'Actual, 'Expected>

Passed, Failed, Exhausted, or Errored depending on the property run.

Example

 let result =
     Check.resultBy(
         (fun verify ->
             FsCheck.Prop.forAll Arbitraries.from<int * int> verify),
         CheckExpectation.isTrue,
         (fun _ -> true),
         <@ fun (a, b) -> a + b = b + a @>)
val result: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int

Check.should (expectation, reference, actual, ?config, ?arbitrary)

Full Usage: Check.should (expectation, reference, actual, ?config, ?arbitrary)

Parameters:
    expectation : CheckExpectation<'Args, 'Actual, 'Expected> - The relation that should hold between tested code and the reference.
    reference : 'Args -> 'Expected - The trusted reference implementation.
    actual : Expr<('Args -> 'Actual)> - The quoted tested function under evaluation.
    ?config : Config - Optional FsCheck configuration override. Typical sources are CheckConfig helpers.
    ?arbitrary : Arbitrary<'Args> - Optional custom arbitrary for 'Args. Typical sources are Arbitraries and Generators helpers.

Runs a property-style check against a reference implementation and raises immediately when it does not pass.

expectation : CheckExpectation<'Args, 'Actual, 'Expected>

The relation that should hold between tested code and the reference.

reference : 'Args -> 'Expected

The trusted reference implementation.

actual : Expr<('Args -> 'Actual)>

The quoted tested function under evaluation.

?config : Config

Optional FsCheck configuration override. Typical sources are CheckConfig helpers.

?arbitrary : Arbitrary<'Args>

Optional custom arbitrary for 'Args. Typical sources are Arbitraries and Generators helpers.

Exception Raised when the check result is anything other than Passed. The message contains the rendered property failure or infrastructure error.
Example

 Check.should(
     CheckExpectation.equalToReference,
     List.sort,
     <@ List.sort @>)
Multiple items
module List from Microsoft.FSharp.Collections

--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T with get member IsEmpty: bool with get member Item: index: int -> 'T with get ...
val sort: list: 'T list -> 'T list (requires comparison)

Check.shouldBy (buildProperty, expectation, reference, actual, ?config)

Full Usage: Check.shouldBy (buildProperty, expectation, reference, actual, ?config)

Parameters:
    buildProperty : ('Args -> bool) -> Property - The callback that constructs the surrounding FsCheck property.
    expectation : CheckExpectation<'Args, 'Actual, 'Expected> - The relation that should hold between tested code and the reference.
    reference : 'Args -> 'Expected - The trusted reference implementation.
    actual : Expr<('Args -> 'Actual)> - The quoted tested function under evaluation.
    ?config : Config - Optional FsCheck configuration override.

Runs a callback-built property check and raises immediately when it does not pass.

buildProperty : ('Args -> bool) -> Property

The callback that constructs the surrounding FsCheck property.

expectation : CheckExpectation<'Args, 'Actual, 'Expected>

The relation that should hold between tested code and the reference.

reference : 'Args -> 'Expected

The trusted reference implementation.

actual : Expr<('Args -> 'Actual)>

The quoted tested function under evaluation.

?config : Config

Optional FsCheck configuration override.

Exception Raised when the check result is anything other than Passed.
Example

 Check.shouldBy(
     (fun verify ->
         FsCheck.Prop.forAll Arbitraries.from<int list> verify),
     CheckExpectation.isTrue,
     (fun _ -> true),
     <@ fun xs -> List.rev (List.rev xs) = xs @>)
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
type 'T list = List<'T>
Multiple items
module List from Microsoft.FSharp.Collections

--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T with get member IsEmpty: bool with get member Item: index: int -> 'T with get ...
val rev: list: 'T list -> 'T list

Check.toDisplayString result

Full Usage: Check.toDisplayString result

Parameters:
    result : CheckResult<'Args, 'Actual, 'Expected> - The property result to render.

Returns: string The configured rendered representation suitable for terminal output or test failures.

Renders a property result using the current Testify report options.

result : CheckResult<'Args, 'Actual, 'Expected>

The property result to render.

Returns: string

The configured rendered representation suitable for terminal output or test failures.

Check.toDisplayStringWith (options, result)

Full Usage: Check.toDisplayStringWith (options, result)

Parameters:
    options : TestifyReportOptions - Rendering options that control output format, verbosity, and related report shaping. See TestifyReportOptions and its helper modules for available options.
    result : CheckResult<'Args, 'Actual, 'Expected> - The property result to render.

Returns: string The configured rendered representation suitable for terminal output or test failures.

Renders a property result with the supplied report options.

options : TestifyReportOptions

Rendering options that control output format, verbosity, and related report shaping. See TestifyReportOptions and its helper modules for available options.

result : CheckResult<'Args, 'Actual, 'Expected>

The property result to render.

Returns: string

The configured rendered representation suitable for terminal output or test failures.

Check.toFailureReport result

Full Usage: Check.toFailureReport result

Parameters:
    result : CheckResult<'Args, 'Actual, 'Expected> - The property result to translate.

Returns: TestifyFailureReport option Some structured failure report when result is Failed, Exhausted, or Errored; otherwise None.

Converts a failing property result into a structured Testify failure report.

result : CheckResult<'Args, 'Actual, 'Expected>

The property result to translate.

Returns: TestifyFailureReport option

Some structured failure report when result is Failed, Exhausted, or Errored; otherwise None.

Type something to start searching.