How to test with CAT in Azure DevOps pipelines

Helena Balzerová
Share it with the world!

CAT loves Azure DevOps

Once you have tested your data with CAT locally, means once having beautiful test sets/project ready, you might wonder how to run it automatically (so also others could see the testing results).
If you are using Azure DevOps as your orchestration tool, you can easily integrate CAT into its pipelines. With such an approach, not only you but also your team can get a feedback on your data quality, right after each code change, thus knowing you can safely release the all new changes to upper environments.
In this step by step guide you will discover all necessary steps to integrate CAT into classic release pipelines by setting up variables, configuring PowerShell tasks, and publishing test results.

Classic release pipeline setup

First of all, lets define variables

First, there are two things you need to put into variables: your license key and version of CAT you want to use. Set the variable for license key as sensitive (using the lock icon). The Variables tab should look like this:

CAT Integration

Integration of CAT into Azure DevOps is simple – it is about running a few commands, actually 3 tasks:
  1. PowerShell task – Installing CAT module
  2. PowerShell task – Executing your tests
  3. Publish Test Results task – Making the results available to everybody 

These tasks we usually put at the very end of the tasks lists.

And now let’s dig deeper into these tasks.

First Task - Install CAT Module

Add first PowerShell task with following parameters:
And in the script section place code installing the CAT module (with the required version number specified as a variable)
Install-Module CAT -AcceptLicense -Force -AllowClobber -Scope CurrentUser -RequiredVersion $(CatVersion)

Second Task - Execute Tests

Add second PowerShell task with following parameters:

In the script section place code that

  • imports CAT module and applies the License Key (defined in the variables)
  • executes the tests stored in the project file.
The only tricky part of this could be setting up where the project file is, but basically, you need to navigate into the build directory of the project.
Here is the code:
Import-Module CAT
Set-CatInstance -LicenseKey $(CAT-license-key)

Invoke-CatProject $(System.DefaultWorkingDirectory)/_your path to the data warehouse/Your ProjectFile.cat.yaml

Third Task - Publish The Results

Finally add Publish Test Results task task with following parameters:

Do not forget, to define Output trx in your project file.

And that's it!

Now, as soon as your pipeline finishes its execution you can immediately see the test results, thus report or debug the bugs found!
(you can find the reports under Tests and coverage label)
Happy testing to everybody 🙂

And do not hesitate to dig deeper into out docs, where you can find much more inspiration how to benefit from using CAT!

Installing CAT

Install CAT

Click to copy the command and paste it into your PowerShell 7 terminal!

Direct Download

Download CAT directly from PowerShell Gallery and give it a try!
OR