Writing tests

With tests you can test part or all of your model. Regression tests can save you a lot of time when making changes to your model.

To access tests functionality navigate to Tests in your selected Project.

Create Test Suites

A Test Suite is a collection of Test Plans. A Test Suite has an associated list of modules that defines the evaluation context (ie the visible Formulas and Table Resources).

../_images/writing-tests-1.png

Create a test suite by clicking on the New test suite button. The application then navigates into the created test suite, where you can see the imported modules and a list containing your test plans.

If you do not have modules in your Project, the module imports input is not displayed.

The formula assets in the Global module are imported automatically for every test suite you create.

../_images/writing-tests-2.png

Create Test Plans

Test Plans tell what Input and Output variables you will use when writing you Test Cases.

Create your test plan by clicking on the New test plan.

Inside the new plan, you can see the input and output variable boxes on the top. These are for selecting which variables you want to give values to in this test.

../_images/writing-tests-3.png

Producing an Output Variable from a given set of Input Variables effectively carves out a part of your expressions in the model.

../_images/writing-tests-4.png

With the variables specified you can easily create multiple Test Cases

It is compulsory to choose at least one output variable, as running a test does not make sense when we have nothing to calculate.

Create Test Cases

Test Cases allow you to set up scenarios with different values for the same set of input/output variables.

Click on the New test case button, a new test case box appears in the list (scroll down if you do not see it). It contains the input and output variables, set the input variables according to your tests.

At this point you can click the Run button below to start the calculation. If it finishes without any problems, the values of the output variables are displayed from the current execution, otherwise the error is displayed.

Each test case (set if input/output variables with input variables set to specific values) allows you to define expectations

At the bottom of each test case box there is a list of Expections where you can write your constraints or expectations for that test case. You have to click on the heading to display the whole list then add a new expectation by clicking on the Add expectation button. An empty expectation appears that is marked as Untested.

Tip

Running your Test Case previously allows you to define expectations according to the output variables displayed.

Type a formula that references some variables from the model you are testing so that you can see its value after the calculation. When you are finished the formula will be converted to the math form but you can still get back the typed form and modify it by clicking into the field.

../_images/writing-tests-5.png

Running Tests

If you run the test case now, this expectation will be evaluated and its status will change according to the result. If the statement you wrote is true, the test case is going to be Successful, if it is false the test case is going to be Failed, ot if there were some errors during the calculation they will be displayed.

When there are multiple test cases you don’t have to run them all one by one, you can click the Run all button at the top of the page, each test case will be evaluated and a summary of expectation statuses displayed.

You can also run all all the test plans in the test Suite at once by clicking on RUN ALL:

../_images/writing-tests-6.png