{"id":2393,"date":"2007-04-27T22:04:00","date_gmt":"2007-04-27T22:04:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/buckh\/2007\/04\/27\/update-to-how-to-run-tests-in-a-build-without-test-metadata-files-and-test-lists-vsmdi-files-test-categories\/"},"modified":"2007-04-27T22:04:00","modified_gmt":"2007-04-27T22:04:00","slug":"update-to-how-to-run-tests-in-a-build-without-test-metadata-files-and-test-lists-vsmdi-files-test-categories","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/buckh\/update-to-how-to-run-tests-in-a-build-without-test-metadata-files-and-test-lists-vsmdi-files-test-categories\/","title":{"rendered":"Update to &#8220;How to run tests in a build without test metadata files and test lists (.vsmdi files)&#8221;: Test Categories"},"content":{"rendered":"<p>&nbsp;<a href=\"http:\/\/blogs.msdn.com\/pierreg\/\">Pierre Greborio<\/a>, a developer over in MSTV, has contributed a great new feature to the <a href=\"http:\/\/blogs.msdn.com\/buckh\/archive\/2006\/11\/04\/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx\">power tool task<\/a> that allows you to run tests without .vsmdi files: test categories.&nbsp; Those of you who have used <a href=\"http:\/\/www.nunit.org\/\">NUnit<\/a> are probably familiar with the <a href=\"http:\/\/nunit.org\/index.php?p=category&amp;r=2.4\">Category attribute<\/a>.&nbsp; Test categories allow you to execute specific groups of unit tests.&nbsp; To tag a unit test method as belonging to a category, just add the Category attribute.&nbsp; Unlike the test container feature, the test category feature will not be in Orcas (if you&#8217;d like to see it in a future release, be sure to <a href=\"http:\/\/blogs.msdn.com\/VSTSQualityTools\/\">let these folks know<\/a>).   <\/p>\n<p>The new version of the TestToolsTask, targets file, and documentation are in an updated&nbsp;zip file attached to the original post, which has also been updated&nbsp;(<a href=\"http:\/\/blogs.msdn.com\/buckh\/archive\/2006\/11\/04\/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx\">download here<\/a>).   <\/p>\n<p>While the details are discussed in the TestToolsTask.doc file, here&#8217;s how to use it.   <\/p>\n<blockquote><p>  <b>Using the new Category attribute<\/b>   <\/p>\n<p>IMPORTANT NOTE: The Category attribute feature will not be included in Visual Studio Codename Orcas.   <\/p>\n<p>The Category attribute must be specified for every test method that should be included in that test category. Note that there is no way to specify that all tests <i>not<\/i> in a test category should be run.   <\/p>\n<p>In order to use categories you need to:   <\/p>\n<p>1. Add a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll in your project.   <\/p>\n<p>2. Add the namespace in the code:<br><font face=\"Courier New\">using Microsoft.TeamFoundation.PowerTools.Tasks;<\/font>   <\/p>\n<p>3. Add the Category attribute to the test method:<br><font face=\"Courier New\">&nbsp;&nbsp;&nbsp; [TestMethod]<br><b>&nbsp;&nbsp;&nbsp; [Category(&#8220;Integration&#8221;)]<\/b><br>&nbsp;&nbsp;&nbsp; public void MyTestMethod()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \/\/ TODO: Add test code here<br>&nbsp;&nbsp;&nbsp; }<\/font>   <\/p>\n<p>Finally, you will either need to specify the TestCategories in TfsBuild.proj if you are using Team Build or modify your project to call the task directly.<\/p>\n<\/blockquote>\n<p>Pierre both wrote and tested the code (making heavy use of <a href=\"http:\/\/www.aisto.com\/roeder\/dotnet\/\">Reflector<\/a>&nbsp;in the process).&nbsp; Thanks, Pierre!<\/p>\n<p>The other feature that&#8217;s new in this release is the support for test names.&nbsp; This just exposes the equivalent to the&nbsp;<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms182489(VS.80).aspx#test\">mstest.exe \/test<\/a> command line switch.&nbsp; The name that&#8217;s specified&nbsp;is&nbsp;implicitly a wildcard match.&nbsp; Specifying &#8220;Blue&#8221; as the test name, for example, will execute every&nbsp;test method that has&nbsp;Blue in the name, including DarkBlue and BlueLight.&nbsp; The TestName property will be available on the Orcas TestToolsTask (beta 2 and beyond).&nbsp; The details are described in the documentation file. <\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:ef8743c5-c289-4664-b3cb-709991fa9c50\">Technorati tags: <a href=\"http:\/\/technorati.com\/tags\/vsts\" rel=\"tag\">vsts<\/a>, <a href=\"http:\/\/technorati.com\/tags\/team%20system\" rel=\"tag\">team system<\/a>, <a href=\"http:\/\/technorati.com\/tags\/tfs\" rel=\"tag\">tfs<\/a>, <a href=\"http:\/\/technorati.com\/tags\/team%20foundation\" rel=\"tag\">team foundation<\/a>, <a href=\"http:\/\/technorati.com\/tags\/team%20build\" rel=\"tag\">team build<\/a>, <a href=\"http:\/\/technorati.com\/tags\/msbuild\" rel=\"tag\">msbuild<\/a>, <a href=\"http:\/\/technorati.com\/tags\/unit%20testing\" rel=\"tag\">unit testing<\/a>, <a href=\"http:\/\/technorati.com\/tags\/nunit\" rel=\"tag\">nunit<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;Pierre Greborio, a developer over in MSTV, has contributed a great new feature to the power tool task that allows you to run tests without .vsmdi files: test categories.&nbsp; Those of you who have used NUnit are probably familiar with the Category attribute.&nbsp; Test categories allow you to execute specific groups of unit tests.&nbsp; To [&hellip;]<\/p>\n","protected":false},"author":94,"featured_media":10268,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[7,8,24],"class_list":["post-2393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-team-build","tag-team-foundation","tag-vsts"],"acf":[],"blog_post_summary":"<p>&nbsp;Pierre Greborio, a developer over in MSTV, has contributed a great new feature to the power tool task that allows you to run tests without .vsmdi files: test categories.&nbsp; Those of you who have used NUnit are probably familiar with the Category attribute.&nbsp; Test categories allow you to execute specific groups of unit tests.&nbsp; To [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts\/2393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/users\/94"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/comments?post=2393"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts\/2393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/media\/10268"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/media?parent=2393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/categories?post=2393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/tags?post=2393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}