Header menu logo testify

TestifyHintRule Module

Helpers for building reusable hint rules.

Functions and values

Function or value Description

TestifyHintRule.create name tryInfer

Full Usage: TestifyHintRule.create name tryInfer

Parameters:
    name : string - The stable rule name.
    tryInfer : TestifyFailureReport -> string option - The callback that inspects the failure report and optionally returns a hint.

Returns: TestifyHintRule A hint rule that can be enabled directly or added to a hint pack.

Creates a hint rule from an arbitrary inference callback.

name : string

The stable rule name.

tryInfer : TestifyFailureReport -> string option

The callback that inspects the failure report and optionally returns a hint.

Returns: TestifyHintRule

A hint rule that can be enabled directly or added to a hint pack.

Example

 let exceptionHint =
     TestifyHintRule.create "Course.Exception" (fun report ->
         match report.ActualObservedInfo with
         | Some info when info.IsException -> Some "Your code raises an exception here."
         | _ -> None)
val exceptionHint: obj
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>

TestifyHintRule.onFieldRegex name field pattern buildHint

Full Usage: TestifyHintRule.onFieldRegex name field pattern buildHint

Parameters:
    name : string - The stable rule name.
    field : HintTextField - The report field whose text should be inspected.
    pattern : Regex - The compiled regex used to detect the hint condition.
    buildHint : Match -> string - Builds the final hint text from the successful regex match.

Returns: TestifyHintRule A hint rule that only fires when the selected field matches the regex.

Creates a regex-based hint rule against one selected report field.

name : string

The stable rule name.

field : HintTextField

The report field whose text should be inspected.

pattern : Regex

The compiled regex used to detect the hint condition.

buildHint : Match -> string

Builds the final hint text from the successful regex match.

Returns: TestifyHintRule

A hint rule that only fires when the selected field matches the regex.

TestifyHintRule.onFieldRegexPattern name field pattern buildHint

Full Usage: TestifyHintRule.onFieldRegexPattern name field pattern buildHint

Parameters:
    name : string - The stable rule name.
    field : HintTextField - The report field whose text should be inspected.
    pattern : string - The regex pattern string used to build a compiled regex.
    buildHint : Match -> string - Builds the final hint text from the successful regex match.

Returns: TestifyHintRule A hint rule that only fires when the selected field matches the compiled regex.

Creates a regex-based hint rule from a regex pattern string.

name : string

The stable rule name.

field : HintTextField

The report field whose text should be inspected.

pattern : string

The regex pattern string used to build a compiled regex.

buildHint : Match -> string

Builds the final hint text from the successful regex match.

Returns: TestifyHintRule

A hint rule that only fires when the selected field matches the compiled regex.

Example

 let trailingWhitespace =
     TestifyHintRule.onFieldRegexPattern
         "String.TrailingWhitespace"
         HintTextField.ActualValue
         @"\s+$"
         (fun _ -> "The value appears to end with trailing whitespace.")
val trailingWhitespace: obj

Type something to start searching.