Skip to content

Add support for user-defined variables in check tests #639

@chrispcampbell

Description

@chrispcampbell

For En-ROADS and C-ROADS, we have a number of check tests that refer to specific years, corresponding to the default start year for some of our sliders. Each year, when we update the default start year for those sliders, we also have to manually update all the tests that have the start year hardcoded. It would be better if we could define a variable for the start year and refer to it instead of having it hardcoded.

For example, here is a test that refers to the current start year of 2025:

- describe: Carbon price
  tests:
    - it: should have output value that matches the input
      scenarios:
        - with:
            - input: Carbon tax initial target
              at: 100
            - input: Carbon tax phase 1 start
              at: 2025
      datasets:
        - name: Carbon tax per tonCO2
      predicates:
        - gt: 0
          lt: 100
          time: [2026, 2034]
        - eq: 100
          time:
            after_incl: 2035

If we had support for user-defined variables, we could do something like this:

- constant:
    - name: start_year
      value: 2025

- describe: Carbon price
  tests:
    - it: should have output value that matches the input
      scenarios:
        - with:
            - input: Carbon tax initial target
              at: 100
            - input: Carbon tax phase 1 start
              at: start_year
      datasets:
        - name: Carbon tax per tonCO2
      predicates:
        - gt: 0
          lt: 100
          time: [start_year + 1, start_year + 9]
        - eq: 100
          time:
            after_incl: start_year + 10

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions