Skip to main content

Testing Decision Tables

The Test tab runs sample inputs through the saved version of a decision table and shows which rules match. You group test cases into test suites, save them with expected results, and rerun them after every change.

Before you begin​

  • Save the table. Tests run on the saved version. For unsaved edits, use Validate, which works on the table as it is in the editor.

Open the test dock​

  1. Select Test in the editor toolbar.

    The dock opens below the grid with a Validation tab and a Test tab. The header shows the table's Version number.

  2. Select the Test tab.

If the table has unsaved edits, Test still opens the dock, but the Test tab shows "Save your changes to test them." and "Tests run on the saved version." Save the table to continue. Any edit to the table also drops the current results.

In the dock header:

  • Select Maximise panel to fill the editor below the toolbar, and Restore panel to go back.
  • Select Close panel or press Esc to close the dock. Esc is ignored while a dropdown or select is open.
  • Drag the Resize problems and tests panel handle to change the height, or focus it and use the arrow keys. The minimum height is 200 px.

Work with test suites​

A test suite is a named set of test cases for one table. The first time you open the Test tab, Studio creates Default Suite. Use the Test Suite selector to switch suites. Switching loads that suite's cases. It's disabled while a run is in progress.

Create a suite​

  1. Open the suite selector and select Create New Suite.
  2. Enter a name in Suite Name.
  3. Select Create.

A name can contain letters, numbers, spaces and underscores. Studio shows "Suite name is required", "Suite name already exists" (names are compared without regard to case) or "Only letters, numbers, spaces, and underscores are allowed" when the name doesn't qualify. Suites can't be renamed.

Delete a suite​

  1. Select the trash icon (Delete test suite) next to the selector.
  2. Confirm "Are you sure you want to delete "X"? All test cases will be removed."

Default Suite can't be deleted.

Export and import a suite​

Select Export to download the suite as <suiteName>.json. Export is disabled when no suite is selected.

To import a suite:

  1. Open the Export menu and select Import.
  2. Select a .json file.
  3. Check the name. It starts as the name in the file, or the file name. A name you enter overrides it.
  4. Select Import.

Studio rejects other file types with "Only .json files are supported." and unreadable files with "Error parsing JSON file. Please check the file format." Without a file, it shows "Please select a file to import". If the name has characters a suite name can't contain, it warns "Imported suite name contains invalid characters. Please update the name."

Add and edit test cases​

  1. Select Add test. It's hidden while a run is in progress.
  2. Enter a value for each input column.
  3. Optionally set the expected result. See Set expected results.
  4. Select Save.

Save saves all the cases in the suite and is enabled only when there are unsaved changes. It shows "Test cases saved successfully", or "The test cases could not be saved. Try again." on failure. It's refused with an inline error when an input is invalid or an expectation is malformed.

Each column takes a typed input:

Column typeInput
StringText.
NumberA number ("Enter X (exact number)").
BooleanA selector with No value, True and False.
DateA date picker (Select date) in YYYY-MM-DD form.
Date Time and TimeISO values.
JSONJSON text.

When an input is invalid, Studio shows "Test case N: ..." and doesn't send that row. The messages are:

  • "X must be true, false or no value"
  • "X must be a finite number"
  • "X must be a whole number between ..."
  • "X must be JSON, for example ..."
  • "Invalid date: ..."

Row actions​

The play icon (Run test case N) runs one case. The "..." (More actions) menu on each row has:

ItemWhat it does
Use last result as expectedSets the expectation from the last result. Disabled, and labeled "run this test first", until the case has a result that isn't an error.
Expect no matchExpects that no rule matches.
Expect error CODEExpects the error code from the last result. Shown only after an error result.
Clear expectationRemoves the expectation. Disabled when there is none.
Duplicate RowAdds an unsaved copy with no result.
Delete RowRemoves the case. Results stay with their rows.

The menu is disabled during a run.

A case's results open under its row when you run it from the play icon. Once there are results, Expand all next to Tests opens the results under every case that has them, and then reads Collapse all.

Set expected results​

The Expected column shows the current expectation and opens the same menu. Its labels are:

LabelMeaning
Not assertedThe case has no expectation.
Expects 12One expected output row, when the table has a single output. Also used for an aggregate value.
Expects tier: Gold, rate: 5One expected output row.
Expects N rowsN expected output rows.
Expects no matchNo rule should match.
Expects error DECISION_XThe case should fail with that code.
, rule X or , N rulesAppended when the expectation names the rules that should match.
Invalid expectationThe expectation is malformed.

The rules for expectations:

  • An empty list of expected rows means zero rows are expected. No list means no row assertion.
  • Other assertions are no match, an aggregate and the matched rules.
  • An error code must look like DECISION_ followed by capital letters, digits or underscores. It can't be combined with expected rows or any other assertion.
  • A malformed expectation blocks Save.
  • Use last result as expected captures the rows, the matched rules and the aggregate. For a result that didn't report rules, such as one from a saved case or a suite run, the case keeps its existing rule and aggregate assertions.
  • Expectations are stored only when you select Save or Run All Tests.

Set the test clock​

Select Test clock to set the time and time zone used for today() and now().

  • Leave the time empty to use the server's current time. The picker then shows "Server time" and the current time in the selected zone.
  • The zone defaults to UTC. Search for any IANA zone to change it. The zone is always sent, so a run is repeatable.
  • The clock isn't saved with the suite.
  • Changing the clock clears all results.
  • It's disabled during a run.

Run tests​

Run a single test​

Select the play icon (Run test case N) on a row. A saved, unedited case runs through the saved test case. A new or edited case evaluates its current values and shows EVALUATED, never PASS, because it isn't compared with a saved expectation.

Run rows as a batch​

Select Run Rows as Batch to evaluate every row in the editor, saved or not, against the current table version and clock in one request.

  • Expectations aren't compared, so each row is EVALUATED or ERROR. There is no PASS or FAIL.
  • A batch can contain at most 1000 rows. Over that, Studio shows "A batch can contain at most 1000 rows; this suite has N."
  • Nothing is saved.
  • The button is disabled with no rows or while a run is in progress.

Run all tests​

  1. Select Run All Tests.
  2. If the suite has unsaved changes, Studio asks "You have unsaved changes in your test suite. Would you like to save before running all tests?" Select Save and Run, or Cancel.

Studio runs the suite on the server and compares each case with its expectation. Each case ends as PASS, FAIL, EVALUATED or ERROR.

Read the results​

The results pane is titled Results. Before a run it shows "No Results" and "Run a test to see the results here."

StatusMeaning
PASSThe result matches the expectation.
FAILThe result differs from the expectation. The row is highlighted.
EVALUATEDThe case ran and has no expectation to compare.
ERRORThe case couldn't be evaluated.

A suite run shows the counts as tags: "N Pass", "N Fail", and "N Evaluated" and "N Error" when they're above zero. A single run shows one status tag. Select the trash icon (Clear results) to clear the results.

The results table has these columns:

  • # and one column for each output.
  • Matched rules, such as "Row 3". A rule not in the current view shows as "Rule X (not in this table view)".
  • Aggregate, such as "sum = 12", for the Collect (Sum), (Min), (Max) and (Count) hit policies.

An empty cell shows "None". A null value shows "No value", an empty string shows "", and Boolean values show True and False.

When no rule matches, the row reads "No matching rules found". When the case couldn't run, it reads "Error: message". An error isn't shown as no match.

If a run fails as a whole, a closable alert shows the reason, such as "The test suite could not be run. Try again." or "The batch could not be run. Try again."

How you know it worked​

The results pane shows a status for every case. A suite run with all cases at "N Pass" and no "N Fail" or "N Error" means the table behaves as you expected.

Next steps​