Business Rules Table
Each row in the Business Rules Table represents an example of a given rule. If a rule fails when a scenario is executed, the remaining rows will still be executed.
A Business Rules Table is useful for validations using a series of data sets. Examples include financial calculations, validations against various data, etc.
Unlike the Business Workflow where you have to implement a Workflow for the underlying fixture to get created, in the Business Rules Table the Fixture gets created automatically when the Business Rules Table is created.
Creating Business Rules Tables
You can create a Business Rules table in two different ways:
- by designing a new table
- by reusing an existing table
Options to create Business Rules Table are available as Content-Assist and Context-Menu on the Scenario Editor. The option Insert a New Business Rules Table will create a new Rules Table along with its underlying Fixture. The option Reuse an Existing Business Rules Table allows you to create a new Rules Table based on an existing Fixture, as described above.
While reusing an existing Fixture, you can choose one or more existing columns (including Assertion columns). You can also add new columns which implies that the existing Fixture gets modified to include corresponding fields for the new columns.
The following screenshot shows the underlying Fixture that gets created for the Business Rules Table that tests the User Registration scenario mentioned above.
Design New Table
You can create a new table can be created using the option Insert a
New Business Rules Table
on the Scenario editor. This creates a new table in which you are required to add the input
columns and the assertion column.
While creating a new table, it is advised that the table name and column names you choose be relevant in a Java context as the column names given are directly mapped to the field names used in the underlying Java fixtures.
Reuse existing table to create a Rules Table
You can also reuse an existing table to create another Business Rules Table using the option
Reuse an Existing Business Rules Table on the Scenario Editor.
You may add or remove columns in addition to the columns reused from the existing table.
To add or remove columns, the option Add/Remove Columns can be used.
This will add columns to a single table while what is visible on the scenario is a view of
that table with a subset or all columns, which essentially are the columns you have selected.
Rename Table or Columns
It is possible to rename an existing Business Rules Table or rename the column names in that table. For this, you select the rename option on the table's context menu that appears on right-click. This will rename a table/column(s) and update the change in the underlying fixtures.
Twist allows you to modify a Business Rules Table which essentially means modifying columns in that table. For this, use the modify option on the table's context menu that appears on right-click. This will add, remove and/or re-order column(s) and update the change accordingly in the underlying fixtures(only relevant to add columns).