TimefoldAI / TimefoldAI/timefold-solver

Allow to disable value range check on ConstraintVerifier for Unit Test

Open
#2,237 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

process/needs triage
Dominant language
Java
Stars
1.8k
Forks
228
Avg merge
1d 13h
Merged PRs (30d)
46

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating ConstraintVerifier and the assertValueRangeForBasicVariables check, then review related tests and issue #2143 for the intended opt-out behavior. Add a way for unit tests to disable the range validation without reconstructing the full value range, and verify both enabled and disabled behavior in ConstraintVerifier tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.