Skip to content

Allow to disable value range check on ConstraintVerifier for Unit Test #2237

@noguespi

Description

@noguespi

There was a change around ~v1.30 which added a assertValueRangeForBasicVariables check that throws if the assigned variable is not within the specified values provided by @ValueRangeProvider.

When I use the ConstraintVerifier to unit test a constraint, it can be cumbersome to recreate the full range of possible values.

Basically when you unit test a constraint, you are giving a solution and expecting some weight/scoring for this constraint. The assertValueRange check forces you to recreate a full fledged solution including the possible values, which may add noise and may not be relevant to the unit test. It adds complexity to the test.

The bypass I have is to pin the variable and customize the @ValueRangeProvider to return the pinned variable when pinned = true. It is not ideal. Related issue: #2143

Metadata

Metadata

Assignees

No one assigned

    Labels

    process/needs triageRequires initial assessment of validity, priority etc.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions