Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

Implementing Traits in custom Visual Studio Test Adapters

$
0
0

Terje Sandstrom has written two excellent blogs on using Traits in Visual Studio Test Explorer.

How to manage unit tests in Visual Studio 2012 Update 1 : Part 1–Using Traits in the Unit Test Explorer

Part 2–Using Traits with different test frameworks in the Unit Test Explorer

In this blog, I will describe how you can implement Traits support for a custom Test adapter. [NOTE: This feature is only available in Visual Studio 2012 Update 1] I will use the XML Test Adapter that I had created in this blog. I will add a category attribute for each test case.

My test xml file looks like this now.

image

I modified XMLTestDiscoverer.GetTests to retrieve the category attribute from the XML and add it to the Traits property of the test case.

image

Now when I open the Test Explorer and the text xml file, I see

image

Super easy. Wasn’t it?

A tip from Terje in this context: Reflection/expression trees must be used to access the Traits property if one wants to be version independent.

 

With Visual Studio 2012 Update 1, we have implemented traits for all out-of-the-box test adapters. These include unit tests for

· C# Desktop

· C++ Native

· C# Windows Store

· C++ Windows Store

· Managed C++

Here is a screenshot of some of the Traits supported by out-of-the-box adapters.

image


Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>