December 6, 2019

How can we associate MsTest test scripts with Azure test cases

  December 6, 2019
Whenever we want to start with automating an application, we start with identifying the test cases which can be and needs to be automated.

So at first, we will have a set of test suites like smoke or regressions suites and there will be corresponding test cases inside it.

Now we will go through those ones by one and automate. Once the scripting is completed, now what?

What we are left with are a set of manual test cases and a set of automated test scripts.

The regular way is that once a release comes we do the automation execution, grab the reports, and attach it to manual test cases written in tools like Jira,Azure,RPM etc.

Again don't you think this is some manual work we are doing by mapping these each time?
So it's time to do a one time linking of manual test cases to corresponding test scripts.

If you are using MsTest as testing framework and Azure as the test management tool, we can do this the easy way.

So let's start with writing a manual test case in Azure.

Writing a test case in Azure

We can start writing a manual test case in Test plans after creating a test suite.

And steps of test cases can be added as below.


Now we have a manual test case written in azure and a unique test case ID will be automatically created.

Writing an automation script for the test case


Then comes the scripting part, Now we need to write the test script using any automation tool (here we use Selenium) with MsTest as the testing framework.

Once the test script is created, it will be shown in the test explorer of the visual studio.


Associating test script with manual test case

Here comes the important part, we need to map our test script to the test case in Azure. So to do this Visual studio provides an easy option called Associate To Test Case in test explorer.

To see this option we need to right-click on the test method name shown in test explorer and the below options can be seen.


*One issue that may happen while going through this option is Associate To Test Case may be disabled by default.

So try the below steps to fix this.
  • Check if the Visual Studio is connected to the Azure/Git project in Teams explorer.

  • Check if there are any Visual studio updates that are pending and do an update if any.
  • Change the Mstest reference as below
[Microsoft.VisualStudio.TestPlatform.TestFramework] to [Microsoft.VisualStudio.QualityTools.UnitTestFramework]

trying out these ones by one in the given order (Check after each step) will get the option enabled.

Now if we click on the associate to test case option we can see the below screen.


Here we need to enter the test case ID we got from Azure and click Add Association.


By doing this, Visual Studio will fetch the test case details from azure and show it in the dialog.
Click on save to see the changes in Azure.


Check associated automation in Azure test case

Let's double-check if the right test method from the visual studio is attached to the test case written in azure.

Go to Test plans > Test suite> Double click to see the test case in define view> Go to Associated Automation tab.

Here you can see the test method name and solution .dll file name which contains the test method.

Test execution history

We have done all this mapping to get track of automation execution on the test case level. So as expected, we can see the execution results along with previous results in azure.

Go to the execute tab in Azure test plans to see this.

Double-clicking on the test case will show the previous execution results.
 Now we are done!!

NB: These can be achieved only if we trigger the test execution from Azure itself, we can't expect to run test scripts in the local visual studio and see the results in the ADO portal.

So the question is how to trigger a Test script from Azure via Test Suite/Test Case? And that's the topic for another blog!
logoblog

Thanks for reading How can we associate MsTest test scripts with Azure test cases

Previous
« Prev Post

No comments:

Post a Comment

How to send email from current Outlook instance using Java + VBScript

If we are using .Net, we can easily access outlook and send emails using its own libraries. But what if we are using Java? Here we can seek ...