简体   繁体   中英

How to automate MDX testing of SSAS

I've developed some MDX queries which are used to test our SSAS cube. I would like to automate these queries so that I could execute them all with a click of a button and ideally green bar/red bar based on their output.

Is there a way I could hook these queries up with Visual Studio to get this behavior?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM