Cell's format in a result-set
Other features offer the opportunity to test the values returned by a query and compare them to expected value. This feature is not working on the value but on the format. This is only relevant for SSAS because this application see the value and the format as two different matters. Suppose that you’ve a measure returning an amount in Euro. Other features of NBi will check that this value is in the correct interval or greater than and so on. But nothing will confirm that the value is rendered as expected to the end-user, with a symbol € and a dot as decimal separator. If you want to perform this test you’ll need to use the matchPattern element as an assertion.
The system-under-test is a query. NBi will only check the first column returned by the query.
The assertion consists of an xml element matchPattern embedding another xml element defining the expected format.
This xml element matchPattern allows the usage of three different children explained here under.
The numeric-format xml element will let the user specify which character will be used as decimal separator (attribute decimal-separator), group separator (attribute group-separator) and how many figures are expected after the decimal symbol (attribute decimal-digits).
The following specification will validate the formatted value of ‘1,152.32’ but not ‘1152,32’ neither ‘1.125,320’
The currency-format xml element is an extension of the previously defined number-format. In addition to the previous attributes, you must also specify the symbol for the currency (attribute currency-symbol) and if this symbol is positioned before or after the value and with or without a space (attribute currency-pattern).
If the two options above don’t cover your needs, you can also make usage of a regular expression. In this case you’ll need to use the xml element regex and assign to it the regular expression.
Reference a format in multiple tests
It’s always useful to define at one place the expected formats. For this you can create references in the settings and define some formats. In teh sample bellow, we’re creating a reference named ‘Standard’
Later in your test, you’ll only need to link the expected format to this reference. Here under, we’re linking our assertion to the reference ‘Standard’ previously defined.
This sample illustrate a query and the corresponding assertion for the format of expected result.