Automate tests with Azure Pipelines using YAML

In this article, you'll learn how to set up and run your canvas app tests built in the Test Studio by using a YAML pipeline in Azure DevOps Services.

You can use a public project on GitHub—Microsoft/PowerAppsTestAutomation—to:

  • Automate the operations of signing in to your application.
  • Open a browser on the build agent and execute a set of test cases and suites.
  • View the status of the test execution in the Azure DevOps pipeline.

Prerequisites

Before you begin, you must complete the following steps:

Step 1 - Fork the PowerAppsTestAutomation project

A fork is a copy of a repository. By forking a repository, you can make changes without affecting the original project.

  1. Sign in to GitHub.

  2. Go to the microsoft/PowerAppsTestAutomation repository. You can also search for microsoft/PowerAppsTestAutomation instead, and then select the repository.

    Search GitHub.

  3. Select Fork.

    Select Fork.

  4. Select where you want to locate the fork.

    Fork account.

Your forked repository will now be available.

Step 2 - Create a test URL .json file

The test URL .json file will contain the test suite and test case URLs for validating your app. The app test suite and test case URLs can be retrieved by selecting the copy play link in Test Studio.

You can find a sample file, Samples/TestAutomationURLs.json, in the repo you created earlier.

  1. Create a new file named TestURLs.json file in your repo, or use any file name you want. The file name and location will be mapped in the pipeline variables later in the document.

  2. Copy the format from the Samples/TestAutomationURLs.json file.

  3. Update the Test URLs section with the tests that you want to validate in your app.

  4. Commit the changes to your repo.

    Update the JSON file.

Step 3 - Create an Azure Pipelines YAML file

You can find a sample file, Samples/azure-pipelines.yml, in the repo you created earlier.

  1. Create a new file named azure-pipelines.yml file in your repo.

  2. Copy the content from the Samples/azure-pipelines.yml file.

  3. Commit the changes to your repo. You'll reference and update the azure-pipelines.yml file when you're configuring your pipeline in Step 4.

Step 4 - Create a GitHub service connection

  1. Sign in to your Azure DevOps instance.

  2. Select an existing project, or create a new project.

  3. Select Project settings at the bottom of the left navigation pane.

    Create a pipeline.

  4. Under Pipelines, select Service connections.

    Service connections.

  5. Select Create service connection.

  6. Select the GitHub service.

  7. Select Next.

    GitHub service connection.

  8. Under OAuth Configuration, select AzurePipelines.

  9. Select Authorize.

    Authorize the service connection.

  10. Optionally, you can update the Service connection name.

  11. Select Save.

    Save the service connection.

Create a pipeline

  1. Select Pipelines in the left navigation pane.

  2. Select Create Pipeline.

    Select Create a pipeline.

  3. Select GitHub YAML.

    GitHub YAML.

  4. Search for or select your repo.

    Select repo.

  5. Select Existing Azure Pipelines YAML file.

  6. Set the path to the Azure YAML pipeline file you created earlier.

  7. Select Continue:

    Review YAML.

    The azure-pipelines.yml file appears.

    Review Azure YAML.

  8. Update repositories name to your repo.

  9. Update endpoint to the name of the GitHub service connection you created earlier.

    YAML endpoint.

  10. Update the TestAutomationURLs file name. This is the test URLs .json file file you created earlier.

  11. Update the LocalProjectName value to your repo name, if you changed it.

  12. Update the TestAutomationURLFilePath to the location of the test URLs .json file in your repo.

    Test parameters.

  13. Select Variables.

  14. Add a variable named OnlineUsername, and set the value to the Microsoft Entra email address of the user context who will sign in to the application. Tests will run under the context of this user account.

  15. Select OK.

  16. Add another variable named OnlinePassword. Set the value to the password of the Microsoft Entra account created earlier.

  17. Select Keep this value secret and Let users override this value when running this pipeline.

    Pipeline variables.

  18. Save and Commit the changes to your repo.

    Save the pipeline configuration.

Run and analyze tests

To validate whether your tests are being successfully executed, select Run. Optionally, you can optionally select the server image to run your tests and also the browser types.

Run job.

As the job runs, select it to see detailed status for each of the tasks that are running.

Job details.

When the job is completed, you can view the high-level job summary and any errors or warnings. By selecting the Test tab, you can view specific details on the test cases you've executed.

The following example indicates that at least one of our test cases has failed while executing the tests by using the Chrome browser.

Chrome - failed.

Select RunTestAutomation to drill into the details about the failed test cases. On the Attachments tab, you can see the summary of the test execution and which test cases have failed or passed in your test suite.

Attachments tab.

Note

If you execute a test suite, you'll see a summary of test cases that have passed and failed. If you execute a test case, you'll see specific details about the failure with any trace information, if available.

Known limitations

  • Multi-factor authentication isn't supported.

  • The test summary will report a single test result per browser. The test result will contain one or more test cases or test suite results.

  • For any authentication process other tha Microsoft Entra sign-in, you'll need to customize the sign-in process in the PowerAppsTestAutomation solution.

See also