Testing a Power BI Desktop solution with NBi

Since the release 1.12 (21-DEC-2015), NBi offers the opportunity to connect to a Power BI Desktop model. Whats does it mean? Simply, that you can interact with the model of your Power BI Desktop solution exactly the same way you’d use a Tabular model hosted by SSAS! You’re able to test the model (existence of tables, columns, …), members of the dimensions (existence, format, ordering, …) and you can execute DAX queries on this model (and compare it to expected results). 100% of feature parity between Power BI Desktop and SSAS Tabular.

How can you achieve this? First, download the last version of NBi and then check how to setup your environment. Once you’re ready, it will be time to define your test-suite.

To define your connection string for a Power BI Desktop solution, you can use the settings element or the connectionString attribute of most of the elements provided by NBi. To explain to NBi that your connection string references a Power BI Desktop solution and not a SQL Server instance, you need to start your connection string by “PBIX = “ followed by the solution’s name (filename without the extension .pbix). At the moment, NBI doesn’t support additional tokens that the PBIX one but it will be improved in a near future.

<settings>
  <default apply-to="system-under-test">
    <connectionString>
      PBIX = My Power BI Desktop Solution
    </connectionString>
  </default>
</settings>

To effectively run your tests, your Power BI Solution must be started! Behind the (not so) closed doors, Power BI Desktop will start a local instance of Tabular SSAS. NBi will detect this instance based on the provided solution’s name and calculate a correct and more complex connection string.

Naturally, you can manually start your PBI Desktop solution and it will be the case when developing your solution. But if your setup is more advanced and you’re on a build or tests server then you’ll need to add some additional steps.

NBi offers a way to the start your Power BI Desktop solution. To do this you need to use the setup element in a test or group.

One of the setuptask is exe-run and the common use is to start some small exe or batch files preparing the environment. In this case we’ll use it to start the Power BI Desktop solution. You need to provide the file path for your pbix solution.

<setup>
  <tasks run-once="true" parallel="false">
    <exe-run name="My Power BI Desktop Solution.pbix"
      path="..\PowerBiDesktop\"/>
  </tasks>
</setup>

This solution has a first problem: the task exe-run will return quickly and the Power BI Desktop solution will not be fully started. At the moment the best way to work-around this issue is to introduce a wait task after the exe-run and ask to wait for 10 seconds.

<setup>
  <tasks run-once="true" parallel="false">
    <exe-run name="My Power BI Desktop Solution.pbix" 
      path="..\PowerBiDesktop\" />
    <wait milliseconds="10000" />
  </tasks>
</setup>

The next problem will occur when you try to run your test-suite many times. You can’t start multiple times the same pbix file. So before proceeding to the exe-run task, we’ll need to ensure that we have no Power BI Desktop solutions open. To do this we’ll kill all the processes corresponding to a Power BI Desktop solutions with the task exe-kill. Note that it will kill all the Power BI Desktop solutions … don’t use this when developing on your laptop!

<setup>
  <tasks run-once="true" parallel="false">
    <exe-kill name="PBIDesktop" />
    <exe-run name="My Power BI Desktop Solution.pbix" 
      path="..\PowerBiDesktop\" />
    <wait milliseconds="10000" />
  </tasks>
</setup>

Feel free to provide feedback by reporting bugs or requesting new features.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s