# Test Studio Tests in Azure DevOps Classic Piepline Using Microsoft-Hosted Agent

<a href="https://www.telerik.com/teststudio" target="_blank">Test Studio</a> tests can be successfully integrated for execution with the Azure DevOps pipelines. This article guides you through an example setup of classic pipeline using Microsoft-hosted agent.

> **Tip!**
> <br>
> Double check if you have covered all <a href="/advanced-topics/build-server/azdo/azdo-pipelines-and-test-studio-tests#choose-the-configuration-to-setup" target="_blank">prerequisites for this setup</a>.

## Create a Free Form Pipeline

1. In the Azure DevOps project go to **Pipelines >> New Pipeline**.

   ![Create new Pipeline](https://www.telerik.com/teststudio/documentation/assets/7a5ae736f3d4018e5db002e16b07b47f/fig9.png)

2. For this setup choose the option to **Use the classic editor**.

   ![Choose classic editor](https://www.telerik.com/teststudio/documentation/assets/c01d57098dc749b09bce90bffbcf4b93/fig10.png)

3. Choose the repository type where the project is and fill in the necessary details to connect to the repo. Click **Continue**.

   ![Choose repo type](https://www.telerik.com/teststudio/documentation/assets/566b4b08efba0a89378714dac161efb7/fig11.png)

4. Choose **Empty job** as a template for the build

   ![Choose empty job](https://www.telerik.com/teststudio/documentation/assets/5dafd01fbce1822954de4b6b1ec6eaf3/fig12.png)

5. Click the **Pipeline** tile and set a meaningful name for the pipeline. Then select the **Agent pool** for Microsoft-hosted agents and choose a default image to be installed on the VM when running the pipeline - you can use *windows-latest*.

   ![Set name and select agent pool for the pipeline, choose agent image](https://www.telerik.com/teststudio/documentation/assets/62d8ca246ee7aa7350b7c4efb813b5db/fig7.png)

6. Continue with adding the Agent tasks as described below.

   > **Tip**
   > <br>
   > Set **all tasks** to **Continue on error** in the task **Control Options** section. This ensures that result upload tasks run even if a previous task fails.
   > <br>
   > <br>
   > All tasks except the first Command Line task (which executes the test run command) are optional.

## Add Universal Download Package Task to Deploy Test Studio Installer on Agent Machine

1. Click the **Agent** tile and create a new **Packages >> Universal Packages** task.

   ![Universal Package task](https://www.telerik.com/teststudio/documentation/assets/c677bb58f7db3be97f8ae6aba06398a8/fig8.png)

2. Set a meaningful name for the **Universal Packages** task. Then set the task command to download action and specify the destination folder.

   ![Download Universal Package task](https://www.telerik.com/teststudio/documentation/assets/b555e0bdfc4912f023d19ebf12ccf7b5/fig9a.png)

3. Verify the **Feed & packages details** section in the **Universal Packages** task and ensure the feed, name and version details of the artifact correspond to details specified when <a href="/advanced-topics/build-server/azdo/azdo-pipelines-and-test-studio-tests#add-test-studio-run-time-installer-as-artifact-in-azdo-project" target="_blank">publishing the installer as an artifact</a>.

   ![Feed & Packages details section](https://www.telerik.com/teststudio/documentation/assets/a79b35467c0896f67bfcfa2dc61ebe6f/fig9.png)

## Add Command Line Agent Task to Install Test Studio Runtime

1. Click the **Agent** tile and create a new **Utility >> Command line** task.

   ![Command line new task](https://www.telerik.com/teststudio/documentation/assets/4911d2653d2363bbb3807421461ad9f0/fig14.png)

2. Set a meaningful name for the **Command Line** task. Then place a command which calls the <a href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec" target="_blank">Windows msiexec command</a> in passive mode. The passive mode is required due to the lack of UI session. Below is an example command to use as baseline in the task.

   ```
   msiexec.exe /i c:\TestStudio_Runtime_2021_3_1103_1.msi /passive /le c:\errorlog.txt
   ```

   ![Install Runtime task](https://www.telerik.com/teststudio/documentation/assets/8b41f7d347cce2bc3e44884400b6cfef/fig10.png)

## Add Command Line Agent Task to Execute Test or Test List

1. Click the **Agent** tile and create a new **Utility >> Command line** task.

   ![Command line new task](https://www.telerik.com/teststudio/documentation/assets/4911d2653d2363bbb3807421461ad9f0/fig14.png)

2. Set a meaningful name for the **Command Line** task. Then place a command which calls the <a href="/features/test-runners/artoftest-runner" target="_blank">Test Studio CLI Runner</a> to trigger the test execution.

   > **Tip**
   > <br>
   > Test Studio CLI runner is called **ArtOfTest.Runner.exe** and provides various execution options. If you are not yet familiar with these check the <a href="/features/test-runners/artoftest-runner#options-to-specify-which-file-to-execute" target="_blank">CLI runner syntax options here</a> to build your command.

3. The sample image executes a test list, sets specific name for the output Test Studio result file and also generates a *junit* type of result.

   ![Execute test list task](https://www.telerik.com/teststudio/documentation/assets/9e49847717629e126077eaa2c9e8b24c/fig15.png)

## Add Publish Test Results Task to Upload JUnit Results

1. Click the **Agent** tile and create a new **Tests >> Publish Test Results** task.

   ![Add Publish Test results task](https://www.telerik.com/teststudio/documentation/assets/2e6b63f892bb5b5bc247fcd73e67b325/fig17.png)

2. Test Studio CLI runner lets you output the execution result in *junit* format and this is the type of result which can be used in this pipeline task.

3. Set a meaningful name for the **Publish Test Results**. Then set the folder where the test results are deployed and choose to upload all .xml files.

   ![Configure Publish Test results](https://www.telerik.com/teststudio/documentation/assets/52996f740218c295bb99130d00e4cfc2/fig18.png)

4. Once the pipeline run is complete the details from *junit* result are visible in the **Test** tab.

   ![See test results](https://www.telerik.com/teststudio/documentation/assets/c52b77a4da4a6bbc91afe9410cc682da/fig19.png)

## Add Publish Pipeline Artifacts Task to Upload the Test Studio Result File

Test Studio test run produces its proprietary test result file which contains additional useful information for the test run. That result file can be very helpful in the case when a test run fails. The **result file always ends with file extension \*.aiiresult** and we recommend to <a href="/features/test-runners/artoftest-runner#result-option" target="_blank">specify its name as part of the command which triggers the CLI runner</a>. That way you can control the upload of the file to the pipeline artifacts.

1. Click the **Agent** tile and create a new **All >> Publish Pipeline Artifacts** task.

   ![Add Publish Pipeline Artifacts task](https://www.telerik.com/teststudio/documentation/assets/7aacb93e46cc6c8a7d95aaa48f5c9713/fig20.png)

2. Set a meaningful name for the **Publish Pipeline Artifacts** task. Then specify the file to upload using the predefined name set in the execution command and define a meaningful name for the artifact.

   ![Configure Publish Pipeline Artifacts task](https://www.telerik.com/teststudio/documentation/assets/1fc5d340fe287b356c2dc6a0785418b7/fig21.png)

3. Once the pipeline run is complete the artifacts are accessible under the **Summary** tab in the **Related** listings.

   ![See published Artifacts](https://www.telerik.com/teststudio/documentation/assets/93235141e9f852b66dda56dc95c56255/fig22.png)

## Add Publish Pipeline Artifacts Task to Upload the Test Studio Failure Details When Available

Test Studio test run produces its proprietary <a href="/automated-tests/test-results/step-failure-details" target="_blank">failure details</a> in case a test run fails. These provide additional context for the specific failure and are very useful for debugging a failing test. The failure details are output in a folder which has the name of the test result and ends with **\*\_files**. Since **these are available only if a test fails** you need to setup a task to check if such folder exists and upload the artifacts only if it does.

1. Click the **Agent** tile and create a new **Utility >> Command line** task.

   ![Command line new task](https://www.telerik.com/teststudio/documentation/assets/4911d2653d2363bbb3807421461ad9f0/fig14.png)

2. Set a meaningful name for the **Command Line** task. Then place a command which checks for the folder using the predefined name of the result file set in the execution command and returns true or false depending on the outcome.

   ![Script to check if a folder exists and set](https://www.telerik.com/teststudio/documentation/assets/713e646618e7583d5058535495c9d855/fig23.png)

3. Click the **Agent** tile and create a new **All >> Publish Pipeline Artifacts** task.

   ![Add Publish Pipeline Artifacts task](https://www.telerik.com/teststudio/documentation/assets/7aacb93e46cc6c8a7d95aaa48f5c9713/fig20.png)

4. Set a meaningful name for the **Publish Pipeline Artifacts** task. Then specify the folder to upload using the predefined name set in the execution command adding the ending **\*\_files** and define a meaningful name for the artifact.

   ![Configure Publish Pipeline Artifacts task for the failure details](https://www.telerik.com/teststudio/documentation/assets/cec51f7691e51d6618ac0ae3ceeed6ef/fig24.png)

5. This task is supposed to be executed only if the failure folder exists. Therefore you need to **specify a custom condition for executing the task**. Expand the **Control Options** section of the task and set the **Custom Condiition** to check the result of the previous **Command Line** task.

   ![Configure control options for Publish Pipeline Artifacts task for the failure details](https://www.telerik.com/teststudio/documentation/assets/81b0bee1d4610ef6a0484ff1f9e8b100/fig25.png)

6. Once the pipeline run is complete the artifacts are accessible under the **Summary** tab in the **Related** listings.

   ![See published Artifacts](https://www.telerik.com/teststudio/documentation/assets/93235141e9f852b66dda56dc95c56255/fig22.png)

## See Also

* <a href="https://www.telerik.com/blogs/using-microsoft-hosted-agents-azure-pipelines-automated-test-execution" target="_blank">Using Microsoft Hosted Agents in Azure Pipelines for Automated Test Execution</a>.

> **Tip**
> <br>
> <br>
> Check out our blog post about <a href="https://www.telerik.com/blogs/using-microsoft-hosted-agents-azure-pipelines-automated-test-execution" target="_blank">Tesitng in Microsoft-hosted agents</a>.
