Business Rules Tables
Business Rules Tables are used to implement tests driven by sets of data. The tables have a set of data columns and one or more assertion columns. If a set of input data (i.e., a rule) fails during execution, the remaining rows will still be executed.
A Business Rule Table has two kinds of columns:
- Input column - These columns represent input data for the given rule.
- Assertion column - These columns represent an expectation. The row fails if, during execution, the value of the column is different from the value specified. Assertion columns have a question mark at the end.
For example:
In Twist, a Business Rules Table to test the functionality for calculating Simple Interest might be described as follows.
| Principal | Tenure | Rate of interest | Interest |
|---|---|---|---|
| 10000 | 4 | 8 | 3200 |
| 0 | 4 | 5 | 0 |
| -100 | 4 | 6 | Invalid Principal amount |
| 5000 | -14 | 6 | Invalid Tenure |
| 3100 | 4 | -6 | Invalid Rate of interest |