Test Table

A test table is used to perform unit tests on executable tables, such as decision tables and method tables. It calls a particular method, provides test input values, and checks whether the returned value matches the expected value. Test tables are mostly used for testing decision tables.

Note: Test tables can be used to execute any Java method but in that case a method table must be used as a proxy.

For example, in the following diagram, the table on the left is a decision table but the table on the right is a unit test table that tests data of the decision table:

Figure 25: Decision table and its unit test table

A test table has the following structure:

User can use the _erorr_ column of Testmethod table to test algorithm where error function is used. OpenL engine compares error message and value of _error_ column to decide is test passed or not.

Figure 27: An example of a test table with a expected error column

Test results can be accessed through the test table API. For example, the following code fragment executes all test runs in a test table called insuranceTest and displays the number of failed test runs:

TableWrapper tableWrapper = new TableWrapper();

TestResult tr = tableWrapper.insuranceTestTestAll();

System.out.println("Number of failed test runs: "+tr.getNumberOfFailures());

If OpenL Tablets projects are accessed and modified through OpenL Web Studio, the user interface provides more advanced and convenient utilities for running tests and viewing test results. For information on using OpenL Web Studio, see OpenL Web Studio User's Guide.