Associating automated tests with Azure Test Cases

I often get asked, “why can’t I update any of the fields on the Associated Automation tab of a Test Case?”

Example of a manual test case with no automation

TL;DR: These fields are read-only in the web portal and can be updated via Test Explorer in Visual Studio.

Why would you want to associate automated tests with Test Cases, a manual testing tool?

  1. End-to-end traceability. By linking your requirements (PBI’s, User Stories) to test cases, you can establish the quality of the requirements based on test results. Ideally a test case is created for each of the acceptance criteria listed for the requirement. Are any of the test cases failing? If so, the requirement is not complete.
  2. More user-friendly. Some of your testers may not be familiar with Azure Pipelines (CI/CD). The automated tests can be run by triggering a Test Case, rather than a pipeline.

Setting up the automated tests

Before we can associate an automated test with a Test Case, we’ll need to do a couple of things. First, the automated tests will need to be stored in source control. This can be GitHub, Azure Repos, Bitbucket, or any other source control provider of your choice. Azure Pipelines can consume code from just about anywhere. Next, we’ll need to build and package our tests by creating a continuous integration build. Finally, our release can consume the build artifact and execute the tests using the VsTest task:

Create a new release definition (or use the application’s release that’s being tested):

Add the build artifact that contains the automated tests:

Add 2 tasks to a stage. In my example I’m using my “Test” environment for the stage. The first task will install the Visual Studio Test Platform. The second task will execute the tests using VsTest. Set the second task’s platform version to “Installed by Tools Installer” so you don’t need to manually install anything on the environment/server that’s running the tests. We’ll be triggering these tests through a Test Case, so set the “Select tests using” field to “Test Run”.

Configuring Azure Test Plans

Next, we can configure our Test Plan to use our build and release definitions. This can be done in Test Plan settings:

We can now execute automated tests in our Test Plan using our automated tests pipeline.

Using Visual Studio to associate to Test Case

The last step is actually associating the tests with Test Cases using Visual Studio. Open the solution containing the tests, then use Test Explorer to right click “Associate to Test Case”:

Find the Test Case:

After saving, you can then find the fields in the Test Case’s Associated Automation tab populated:

Running the tests

Finally, testers can now trigger the automated Test Case!

Then see the results in Test Runs:

Happy testing!

My examples use the open source TailSpin Space Game web application that can be found on GitHub here:

21 thoughts on “Associating automated tests with Azure Test Cases

  1. Thanks for the stepwise details.I have a doubt regarding this step — Using Visual Studio to associate to test case.
    My automated test cases are in Robot framework. Then how can I associate them

  2. Very good example and summary. I’ve been able to use the Visual Studio Test Explorer to do this successfully. However, do you know if there is a similar associate test case option in Visual Studio Code? I’ve been doing research and there doesn’t appear to be, nor an extension that seems to provide it either.

      1. Did you find a solution? is there any di vs dode extension? I looked for one but I didn’t find it, I know you can search for the Azure API, but it would require the construction of a tool for that

  3. Very good description! Is it possible to pass parameters from the test case as input to the test code, e.g. the test data location? Or is there any other recommended way?

  4. Good piece of information!

    Is it possible to have a Test Case linked to an automated test case and at the same time have it for manual testing? Meaning that the test case can be tested manual or automatically, at tester discretion?


    1. can somebody please help if we can update Associate Automation field in test Plan in Azure DevOps when we run Selenium automated test cases in eclipse.

      Thanks in Advance.

  5. Is it possible to associate many test scripts in Visual Studio to one manual test case in Azure? I have one manual test on ADO and for which I have 4 small test methods (divided across different Visual Studio projects).

    1. It is not possible to associate multiple automated test scripts to a manual test case in Azure DevOps. Please read this notes:

      Which says “The dialog shows a list of test cases currently associated with the selected test method. You cannot associate more than one test method with a test case, but you can associate a test method with more than one test case.”

  6. How to associate my Azure DevOps test cases with GitHub automation solution using visual studio or any other ways?

  7. Using github for code repos. Unable to associate tests in VS Test Explorer to Tests in azure test cases. Any one knows a way to do it ?

Leave a Reply

Your email address will not be published. Required fields are marked *