Contents

Assertions

Unofficial Content

Assertions are the only way to define if a test pass or fail, by comparing the result that you get against what you expect.

An assertion is a procedure that receives three parameters, compare the first two and displays a message (set by the user) if they are different. Through assertions the value obtained is verified in order to check if it is correct. This means that the assertions tests that obtained value equals the expected one. You can also test if database table rows are in the state expected or if a SDT has the correct data.

You can add as many assertions as you want, but if at least one of them fails, the Test will be marked as FAILED and the error message will be displayed on the Test Results panel. Otherwise, the test will PASS.

Currently, there are only 2 types of assertions in the Unit Testing Module:

AssertNumericEquals (in:&ExpectedValue, in:&ObtainedValue, in:&FailureMessage)

to verify that 2 numeric values are equals.

AssertStringEquals (in:&ExpectedValue, in:&ObtainedValue, in:&FailureMessage)

to verify that 2 strings are equals.

AssertStringEquals is the most generic and useful function since almost any structure can be serialized as a string.

For example, if you want to test a procedure that uses a SDT as output, you can test its functioning (all the data is the expected) by converting the SDT to a JSON.

AssertStringEquals(&SDTcountryExpected.ToJSON(), &SDTcountryObtained.ToJSON(), “The country data is different”)

You might want to test a specific field of the SDT. You can do this by placing the expected field first and then the one that is going to be tested (which is the obtained).

AssertStringEquals(&SDTexpected.fieldX, &SDTobtained.fieldX, “Field X is wrong”)