{"id":35426,"date":"2017-08-18T14:13:59","date_gmt":"2017-08-18T21:13:59","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/devops\/?p=35426"},"modified":"2019-02-14T15:51:21","modified_gmt":"2019-02-14T23:51:21","slug":"the-testcontainer-capability","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/the-testcontainer-capability\/","title":{"rendered":"The TestContainer Capability"},"content":{"rendered":"<p>Updating off pre-RTM bits once RTM ships ought to be routine. But if you have not already done so in the case of the .NET Core based Test projects, let me give you a reason to do so.<\/p>\n<p><a href=\"https:\/\/github.com\/Microsoft\/vstest\">vstest<\/a> delegates discovery and execution of tests to test-framework-specific adapters. Adapters indicate the kind of test containers that they can process \u2013 for e.g. in the case of .NET based test frameworks like MSTest, xUnit, NUnit, etc. their adapters would indicate that they can discover and execute tests from &#8220;.DLL&#8221; files. Now imagine a solution producing say 20 DLLs, and having test projects that use xUnit (or NUnit, or MSTest). When it comes time to discover tests, the Visual Studio Test Explorer hands off all 20 DLLs to the adapter. But say only 2 of those DLLs contained tests while the other 18 DLLs were product code. The adapter ends up rejecting those 18 DLLs, and processing only the 2 DLLs. Due to this activity with the non-tests DLLs, there is a performance hit, and there are avoidable diagnostics spewed out. Had there been other adapters that had indicated that they could process \u201c.DLL\u201d files, the 20 DLLs would have been handed off those adapters as well.<\/p>\n<p><strong>An optimization in the Visual Studio Test Explorer<\/strong>\nWhat is needed is distinguishing DLLs capable of containing tests.<\/p>\n<p>Which brings us to &#8220;capabilities&#8221;. Project capabilities \u2013 documented <a href=\"https:\/\/github.com\/Microsoft\/VSProjectSystem\/blob\/master\/doc\/overview\/about_project_capabilities.md\">here <\/a>&#8211; are the recommended way to determine the type, platform, and features of a project. We have started leveraging this for .NET Core Test projects. .NET Core Test projects referencing the <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.NET.Test.Sdk\/\">Test SDK <\/a>v15.0.0 and above have a capability called \u201cTestContainer\u201d that distinguishes them as a test project. Issue <a href=\"https:\/\/github.com\/Microsoft\/vstest\/pull\/440\">#440<\/a> on GitHub traces the details for this feature.<\/p>\n<p>Starting with Visual Studio 15.3 Preview 4, the Test Explorer hands off only the projects that have this capability to the relevant adapters. Going by the earlier example, only the 2 test projects will be handed off to the adapters! This streamlines the experience from both the performance and diagnostics perspectives.<\/p>\n<p>The <a href=\"https:\/\/www.nuget.org\/stats\/packages\/Microsoft.NET.Test.Sdk\">.NET Core Test SDK<\/a> went RTM with v15.0.0 (more than 6 months back).\n.NET Core Test project referencing a pre-RTM version of the Test SDK do not have this capability, and test from such projects will not get discovered in the Test Explorer of Visual Studio 15.3 Preview 4 and above (there is no impact to CLI and CI scenarios). But this is easily addressed \u2013 on such old test projects, just upgrade your Test SDK reference to the latest!<\/p>\n<p>There, now you have a reason to update.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updating off pre-RTM bits once RTM ships ought to be routine. But if you have not already done so in the case of the .NET Core based Test projects, let me give you a reason to do so. vstest delegates discovery and execution of tests to test-framework-specific adapters. Adapters indicate the kind of test containers [&hellip;]<\/p>\n","protected":false},"author":765,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,252],"tags":[],"class_list":["post-35426","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>Updating off pre-RTM bits once RTM ships ought to be routine. But if you have not already done so in the case of the .NET Core based Test projects, let me give you a reason to do so. vstest delegates discovery and execution of tests to test-framework-specific adapters. Adapters indicate the kind of test containers [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/35426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/765"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=35426"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/35426\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=35426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=35426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=35426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}