title | description | ms.assetid | ms.service | ms.custom | ms.topic | ms.author | author | ms.date | monikerRange |
---|---|---|---|---|---|---|---|---|---|
Associate automated tests with test cases |
Continuous testing. Associate an automated test with a test case using Microsoft Test Manager and Azure DevOps with a build or release pipeline |
606679F2-1604-40EA-A720-63CDDA93DD76 |
azure-devops-test-plans |
UpdateFrequency3 |
how-to |
jeom |
rohit-batra |
01/28/2025 |
<= azure-devops |
[!INCLUDE version-lt-eq-azure-devops] [!INCLUDE version-vs-gt-2015]
Associating automated tests with test cases can enhance your testing process by providing better traceability and integration with your CI/CD pipeline. This article guides you through the scenarios where associating automated tests with test cases is beneficial and how to do it effectively.
[!INCLUDE prerequisites]
Do the following steps to create a test project and build pipeline.
- Create a test project containing your automated test. For more information, see what types of tests are supported.
- Check your test project into an Azure DevOps.
- Create a build pipeline for your project and ensure that it contains the automated test. For more information, see what the differences are if you're still using a XAML build.
Consider using Visual Studio to associate automated tests with a test case in the following scenarios:
-
Automating manual test cases: If you created a manual test case that you later decide is a good candidate for automation, but you still want to run it as part of a test plan. You can run these tests in the CI/CD pipeline by selecting the test plan or test suite in the settings of the Visual Studio Test task. You can also run automated tests from the Test Plans web portal. If you're using XAML builds, you can run these automated tests using Microsoft Test Manager.
-
Enabling end-to-end traceability: If your test cases are linked to requirements or user stories, you can use the results of the test execution to establish the quality of those requirements.
Do the following steps to associate your automated test with a test case in Visual Studio.
-
Open your solution in Visual Studio Enterprise or Professional 2017 or a later version.
-
If you don't know the identifier of the work item for the test case, locate the test case in Azure Test Plans , or query for the work item in the Work hub.
-
When you know the identifier of the work item for the test case:
If you're using Visual Studio 2017 or later version, do the following steps to associate your tests.
- If the Test Explorer window isn't displayed, open it from the Test | Windows menu.
- If your tests aren't displayed in Test Explorer, build the solution.
- In Test Explorer, select the test method you want to associate and choose Associate to Test Case.
- In the dialog that opens, type the test case identifier and choose Add Association, then choose Save.
The dialog shows a list of test cases currently associated with the selected test method. You can't associate more than one test method with a test case, but you can associate a test method with more than one test case.
If you're using the build and release services in Azure DevOps, not a XAML build, you can run associated tests in the build and release pipelines by using the Visual Studio Test task. You can't run tests on-demand using Microsoft Test Manager unless you're using a XAML build.
The parameters in a test case aren't used by any automated test that you associate with a test case. Iterations of a test case that use these parameters are for manual tests only.
For more information, see the following articles:
- Add files to the server
- Continuous integration on any platform
- Recording and Playing Back Manual Tests
- Use UI Automation To Test Your Code
-
Navigate to Pipelines and choose a pipeline where the automated tests ran.
-
Choose the build in which your tests were executed.
-
In the Tests tab, look for the automated test you wish to link with a manual test case.
-
Select the test and then click on Associate Test Case.
-
Locate the manual test case you want to associate to the automated test and click Associate.
After you associate your automated tests with their corresponding test cases, you can utilize the Azure Test Plan task to execute them as part of a pipeline.
See the following frequently asked questions (FAQs).
A: The following capabilities and limitations exist for each test type:
Framework | *Association in Visual Studio | Association in Azure DevOps |
---|---|---|
Coded UI tests | Supported | Supported |
Selenium | Supported | Supported |
MSTest v1/v2 | Supported | Supported |
NUnit | Supported | Supported |
xUnit | Supported | Supported |
Python (PyTest) | Not Supported | Supported |
Java (Maven and Gradle) | Not Supported | Supported |
* Supported in Visual Studio 15.9 Preview 2 or later.
Tests that use the .NET core framework can be associated with a test case work item when using Visual Studio 15.9 Preview 2 or later. Run the .NET core tests. The appropriate target framework must be specified in a .runsettings file.
A: As long as you run your automated tests in Azure Pipelines with the VSTest task, or you report the test results with the PublishTestResults task, the automated tests will be available for association to test cases. Please keep in mind that the test must run at least once before it becomes available for association.
A: If you're using a XAML build in Azure Pipelines, you can run tests that you associated in a Build-Deploy-Test workflow using a Lab environment. You can also run tests using Microsoft Test Manager and a Lab environment.
A: Yes. If you want test work items to open inside Visual Studio instead of the default Azure Pipelines UI in your web browser, change the Work Items | General setting from the Tools | Options menu in Visual Studio.