Get Help

Tolerance

Is the difference between two values negligible? Use the Tolerance property.

Two sets can differ by an amount that does not matter to the test:

First set Second set
81.99999 82.0
82.00001 82

Tolerance tells Sets match and Contains how far apart two numbers may be and still match. It applies to every pair of values that both read as numbers; text, dates and NULLs are unaffected.

Absolute tolerance

Tolerance states how large a difference still counts as equal, in the unit of the values:

- Name: compare actual results with expected results
  Expectation: sets match # works for the contains expectation too
  Tolerance: 0.01
  # other test settings here

Tolerance mode: absolute is the default and may be omitted.

Tolerance in percent

With Tolerance mode: percent the tolerance is a percentage. The value is given in percent — 1.5 means 1.5 %; CAT divides by 100.

The base of the percentage is always the higher of the two numbers.

A complete project using tolerance in percent. Both sets are entered data, typed into the tests:

Data sources: [] # every value is entered in the tests

Tests:
- Name: Within percent tolerance
  Order: 1
  Description: This should pass, as the difference is within percent tolerance
  First Data Source: EnteredData
  First Query: |
    Year, Profit
    2021, 1000
    2022, 1500
  Second Data Source: EnteredData
  Second Query: |
    Year, Profit
    2021, 1010
    2022, 1500
  Expectation: sets match
  Tolerance: 1.5 # this means 1.5 % (so it is exactly 1.5 when the base is 100)
  Tolerance mode: percent

- Name: Outside percent tolerance
  Order: 2
  Description: This should fail, as the difference is outside the defined tolerance
  First Data Source: EnteredData
  First Query: |
    Year, Profit
    2021, 1000
    2022, 1500
  Second Data Source: EnteredData
  Second Query: |
    Year, Profit
    2021, 1010
    2022, 1500
  Expectation: sets match
  Tolerance: 0.0001
  Tolerance mode: percent

- Name: Tolerance in percent the same as difference
  Order: 3
  Description: This should pass, as the difference is within the percent tolerance
  First Data Source: EnteredData
  First Query: |
    Year, Profit
    2021, 1000
    2022, 1500
  Second Data Source: EnteredData
  Second Query: |
    Year, Profit
    2021, 1010
    2022, 1500
  Expectation: sets match
  Tolerance: 1 # the difference is 10; one percent of the higher value, 1010, is 10.1
  Tolerance mode: percent

Defaults

Without Tolerance and Tolerance mode, CAT uses Tolerance mode: absolute and Tolerance: 0 — the slightest difference between numeric values fails the test. A Tolerance mode other than absolute or percent is an error.