Article
· May 14, 2023 2m read

Unit Tests for InterSystems IRIS BI Dashboards and Pivots

Hi Developers!

Often solutions with InterSystems IRIS BI can turn into a quite big solution with dozens of pivots and dashboards.

With every new IRIS BI solution release we can add changes that could influence the behavior of existing pivots or dashboards so they stop working. For example if we change the dimension or measure name, forget deploying some cubes or subject areas, conduct refactoring via mass renaming of cubes and its elements etc some widgets could stop functioning.

The solution is to test (manually?) every widget in every dashboard if the MDX queries are working.

Today I want to introduce a tool to test all the pivots and dashboards automatically.

Install isc-dev IPM module created by @Gevorg Arutiunian  as:

USER>zpm "install isc-dev"

or programmatically:

set sc=$zpm("isc-dev")

NB: You'd need to have IPM client installed. If you don't have it you can use the following one-liner:

s r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ISC.FeatureTracker.SSL.Config" d r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")

The installed isc-dev module has two methods that could help in automatic testing. Here is the widget to test all the pivots:

set sc=##class(dev.bi).checkPivots()

If there are issues the sc will contain errors. 

Also there is an option to stop on first error:

set sc=##class(dev.bi).checkPivots(1)

in this case you'll be presented to the first not working pivot which is provided via the util's log on the terminal.

Another utility will help to check all the dashboards:

set sc=##class(dev.bi).checkDashboards()

it will control all the widgets and its filter settings.

This two utilities are very handy to use in unittests. Here is an example of universal unittest class that I can recommend to use in any IRIS BI solution:

Class dc.irisbi.unittests.TestBI Extends %UnitTest.TestCase
{

Method TestPivots()

{

Do $$$AssertStatusOK(##class(dev.bi).checkPivots(),"Test Pivots")

}


/// Test dashboards in BI package
Method TestDashboards()

{

Do $$$AssertStatusOK(##class(dev.bi).checkDashboards(),"Test Dashboards")

}

}

And here is the template project that uses it.

See how it works in a related video.

Hope this article is useful and will save a lot of important developers' time!

Happy coding!

Discussion (3)2
Log in or sign up to continue