Skip to content

custom stopping criteria for tests #256

@ghilesZ

Description

@ghilesZ

Hi,

I can't find a way in the documentation to stop a test when a given criterion is met.
Is there an way to do that using the current API?

Ideally i would like to have an additional parameter to the function Test.make*, let say a predicate ?until: () -> bool, that would be called at each iteration, an if it returns true, stop the testing. This could be useful in many cases, eg, if the function under test has a behavior that depends on an external environment, or if we want to test a function until its coverage is more than a threshold etc.

The Test.make function would have as a signature something like:

val make : 
  ?if_assumptions_fail:([ `Fatal | `Warning ] * float) ->
  ?count:int ->
  ?long_factor:int ->
  ?max_gen:int ->
  ?max_fail:int ->
  ?small:( 'a -> int ) ->
  ?retries:int ->
  ?name:string ->
  ?until:(unit -> bool)
  'a arbitrary ->
  ( 'a -> bool ) ->
  t

I am willing to participate to the development of such a feature if you think it's a good idea.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions