Skip to content

Allow guards on tests to scope the random input values of the test #860

@joukestoel

Description

@joukestoel

It would be nice if we could use guards to scope random test parameters.
For instance we could then write the following test:

test bool createDate_withBoundedYearMonthAndDay(int year, int month, int day) =
  date.year == year && date.month == month && date.day == day
  when
    year > 0 && year < 3000 &&
    month > 0 && month < 13 &&
    day > 0 && day < 29 && // not entirely accurate, but hey ...
    date := createDate(year, month, day);

The test runner should recognise when a test was executed successfully because the body of the test passed or if it succeeded because the guard failed. Failed execution attempts because of failure to fulfil the guard should be recorded separately from the general test execution runs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions