How to automate MDX testing of SSAS

自古美人都是妖i 提交于 2019-12-06 15:32:25

You can try any unit testing framework here. Although unit tests aren't intended for such use, they can be useful there - test runners have red/green indicator out of the box.

Write test which executes mdx using ADOMD.NET ( http://j.mp/NtKFih ) and exception during execution will fail test. You can also investigate result using CellSet object and decide if test has passed.

Simple example using Microsoft's Unit Testing Framework (references To System.Data.dll and Microsoft.AnalysisServices.AdomdClient.dll are required):

using Microsoft.AnalysisServices.AdomdClient;
...
[TestMethod]
public void CubeHealthCheck1()
{
    using (AdomdConnection conn = new AdomdConnection("Data Source=localhost;
           Initial Catalog=SejmCube")) //your connection string here
    {
        conn.Open();
        AdomdCommand cmd = conn.CreateCommand();
        //your mdx here
        cmd.CommandText = "SELECT NON EMPTY { [Measures].[Glosow Przeciwko] } 
                           ON COLUMNS FROM [Sejm]";
        CellSet cs = cmd.ExecuteCellSet();
    }
}

Any exception will fail test (no connection for example) - you can add try/catch and in message inform what went wrong.

You can run this test from for example Test List Editor window

and then in Test Results window you have result with indicator

If you don't want using unit testing framework, you can develop custom visual studio extension (http://j.mp/QfMNQt) with similar logic inside.

You should check Nbi. This framework let you check the structure and members of your cubes but also compare query, mdx or sql, results to predefined or dynamic results. The documentation is relatively exhaustive for an open-source project.

Compared to other solutions, you don't need to code in C#, just an Xml file describing your tests is enough.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!