Performance Zone is brought to you in partnership with:

I'm an independent consultant working in Italy with more than 8 years of experience in designing and developing application for .NET framework, both in windows and Web environments. I'm particularly involved in Continuous Integration strategies, and designing infrastructure of applications, since I'm a lover of pattern and Application Lifecycle Management. I'm a great fan of Communities and I'm a co-founder of DotNetMarche, an Italian community focused on .NET development and I love blogging about technology. Ricci is a DZone MVB and is not an employee of DZone and has posted 36 posts at DZone. View Full User Profile

New Unit Test functionality in VS2012 Update 2: Test Playlist

03.15.2013
| 2319 views |
  • submit to reddit

In VS2012 we have support for basically any Unit Test Framework, because the new test runner is plugin based, and everyone can write plugin to make it compatible with the framework of choice. From the original version that was released with Visual Studio 2012 RTM, in Update 1 and Update 2 the test runner gained a lot of new feature, really useful for everyday work.

Update 2 introduced the concept of “Test Playlist”: basically a simple tool to create a subset of Unit Tests that are meant to be managed together. Since Update 1 already introduced the concept of Traits to group tests, this feature can be seen as a duplicate, but traits and playlist have different meaning. Let’s see how to create a playlist.

To create a list simply choose one or how many tests you like in test explorer, right click on one of them and choose Add to Playlist; if there is no playlist already loaded, the only option is “New Playlist”, just give the playlist a name and a location and create a new one.

image

Figure 1: Create a playlist from a test in Test Explorer

Now you can continue to add other test to the playlist if you want; once you are done you can select the playlist from the top menu of the Test Explorer.

image

Figure 2: You can now choose the playlist to use.

A playlist is just an XML file that contains the list of all the test you added to the playlist. To continue adding test to the playlist you should use the top Menu to select “All Tests”, find tests you want to add to the playlist, and simple right click and choose to “Add to Playlist”; now you should see all the testlist of the project and not only the “new Playlist” option.

Once you select a playlist, the test runner works exactly as before, but it consider only the tests included in current playlist, you can filter, group by traits, etc etc. To remove a test from a playlist, simply choose that playlist, right click on the test (or the tests) you want to remove and choose: Remove from current playlist.

As I told at the beginning of the post: the use of playlist is an alternative to use Traits to group test and run only a subset, but the main difference is that a Trait expresses a real property of the test, (ex the logical area of the software that got tested, or other attribute such Database to indicate that it needs a test database), while playlist are primarily meant to group together heterogeneous tests to simplify management, both for running test and manage them.

image

Figure 3: Group by traits.

This feature is also needed by all old MsTest users, that are used to create list of test to run with the old test runner.




Published at DZone with permission of Ricci Gian Maria, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)