December 15, 2019

How to apply Test filter criteria in Azure VsTest task and in MsTest framework

  December 15, 2019
If we consider an automation suite, we can have different kinds of suites like smoke tests, regression tests, module based tests etc.

TestCategory in MsTest

Within the Visual studio we can group these by using MsTest unit testing framework.
In MsTest we need to use TestCategory annotation to achieve this.

Lets's consider below example.

        [TestMethod, TestCategory("CICD Demo"), TestCategory("CICD Smoke Test")]

        public void CICD_Excel_Demo()
        {
            WriteLog("Pass", "Test log");
                   
        }

Here we have used two tags "CICD Demo" and "CICD Smoke Test" to group this test case.

This will be shown in test explorer as below.


Test filter criteria in Azure

The same Test category we mentioned in our C# code , we can use in Azure VsTest task to run test cases based on those category as filter.

To achieve this we need to select Select tests using in VsTest task as "Test assemblies" and mention the project dll.



My mentioning the Test files as the solution dll, VsTest task will check the whole project and identify all the methods with "TestMethod" tag.

Now we can set the test filter criteria in any build/release pipeline VsTest task like below.



If we are referring any artifact to find the project dll. we can mention the search folder.

Now from all the found tests from the project, VsTest will filter the test based on the criteria provided and those tests only will be executed.

Some points to be noted


  • If "Test assemblies" option is used, a test run will be created against this execution and all the results will be shown in there. If we have mapped any manual tests from test plans to these test scripts, those will not updated as execution history.
  • Test results while using this mode of execution can be found in Pipelines/Release section and in Test runs section.
Pipelines/Release section of the job with the VsTest task


Inside the test run section

  • Basically, Associate test case option of visual studio will not be having any impact here.
  • This option helps us to execute test from azure without any test cases written in test plans.
  • We can use this VsTest task as the only job in a release and that can be used as release to do testing only or it can be used as part of release jobs like in normal cases.
  • We can give more than one Test category in MsTest test method and same can be used in VsTest test filter.
logoblog

Thanks for reading How to apply Test filter criteria in Azure VsTest task and in MsTest framework

Previous
« Prev Post

No comments:

Post a Comment

Bookmark this website for more workarounds and issue fixes.

Verify Zip file contents without extracting using C# + Selenium

While doing automation testing, we may get a scenario where we need to download a zip file and to validate the contents inside it. One way t...