New Unit Test functionality in VS2012 Update 2: Test Playlist
Join the DZone community and get the full member experience.Join For Free
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.
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.
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.
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, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.