{"id":28125,"date":"2017-03-02T20:41:51","date_gmt":"2017-03-03T03:41:51","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/?p=28125"},"modified":"2019-02-14T15:55:48","modified_gmt":"2019-02-14T23:55:48","slug":"accelerated-continuous-testing-with-test-impact-analysis-part-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/accelerated-continuous-testing-with-test-impact-analysis-part-1\/","title":{"rendered":"Accelerated Continuous Testing with Test Impact Analysis &#8211; Part 1"},"content":{"rendered":"<h3>Continuous Testing in DevOps<\/h3>\n<p>In older testing strategies, large software changes were tested as a complete product after a so called &#8220;release to QA&#8221;, running almost all tests just before release. We know the downsides to that. On the other hand, DevOps is all about a fast development to delivery pipeline and continuous delivery of value. Releases are happening in days and weeks &#8211; not in years as they used to. In such a DevOps world, there is not going to be any continuous delivery if you do not have your testing right. Just as we have CI Continuous Integration (CI) and Continuous Delivery (CD), DevOps calls for Continuous Testing (CT).<\/p>\n<h3>Test Impact Analysis (TIA)<\/h3>\n<p>Can such continuous testing also be fast? Can it still be comprehensive? Should you just run all your tests all the time? At smaller scales running through all your test suites and emitting\u00a0out copious test results may be tolerable, but this not scale. At a larger scale, for testing cycles to be fast, a more sophisticated view of what is comprehensive testing becomes essential. &#8220;Relevance&#8221; becomes critical &#8211; only run the most relevant tests and only report the relevant results.<\/p>\n<p>The Test Impact Analysis (TIA) feature specifically enables this &#8211; <strong>TIA is all about incremental validation by automatic test selection<\/strong>. For a given code commit entering the pipeline TIA will select and run only the relevant tests required to validate that commit. Thus, that test run is going to complete faster, if there is a failure you will get to know about it faster, and because it is all scoped by relevance, analysis will be faster as well.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/TIA3.jpg\"><img decoding=\"async\" width=\"879\" height=\"518\" class=\"alignnone wp-image-28145 size-large\" alt=\"tia\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/03\/TIA3-1024x603.jpg\" \/>\n<\/a>TIA does come with a little overhead of its own (in order to build and maintain the mapping), and so is best applied only in cases where a test run itself takes a little long to complete (say, &gt; 15 mins).<\/p>\n<h3>Enabling TIA<\/h3>\n<p>TIA is supported via the Version 2.* of the Visual Studio Test task. If your application is a single tier application, all you need to do is to check \u201cRun only impacted tests\u201d in the task UI. The Test Impact data collector is automatically configured. No additional steps required.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/VSTestv2task.jpg\"><img decoding=\"async\" width=\"695\" height=\"559\" class=\"alignnone size-full wp-image-28095\" alt=\"vstestv2task\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/03\/VSTestv2task.jpg\" \/><\/a><\/p>\n<p>If your application interacts with a service in the context of IIS, you need to additionally configure the Test Impact data collector to run in the context of IIS (via a .runsettings file). Here is a sample that does this configuration:<\/p>\n<pre><span style=\"font-size: 8pt\"><span style=\"color: #0000ff\">&lt;?<\/span><span style=\"color: #800000\">xml<\/span> <span style=\"color: #ff0000\">version<\/span><span style=\"color: #0000ff\">=\"1.0\"<\/span> <span style=\"color: #ff0000\">encoding<\/span><span style=\"color: #0000ff\">=\"utf-8\"?&gt;<\/span>\n<span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">RunSettings<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>  <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">DataCollectionRunSettings<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>    <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">DataCollectors<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>      <span style=\"color: #0000ff\">&lt;!--<\/span> <span style=\"color: #008000\">This is the TestImpact data collector.<\/span><span style=\"color: #0000ff\">--&gt;\n<\/span>      <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">DataCollector<\/span> <span style=\"color: #ff0000\">uri<\/span><span style=\"color: #0000ff\">=\"datacollector:\/\/microsoft\/TestImpact\/1.0\"<\/span> <span style=\"color: #ff0000\">assemblyQualifiedName<\/span><span style=\"color: #0000ff\">=\"Microsoft.VisualStudio.TraceCollector.TestImpactDataCollector, Microsoft.VisualStudio.TraceCollector, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"<\/span> <span style=\"color: #ff0000\">friendlyName<\/span><span style=\"color: #0000ff\">=\"Test Impact\"&gt;\n<\/span>        <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">Configuration<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>          <span style=\"color: #0000ff\">&lt;!--<\/span> <span style=\"color: #008000\">enable IIS data collection<\/span><span style=\"color: #0000ff\">--&gt;<\/span>\n          <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">InstrumentIIS<\/span><span style=\"color: #0000ff\">&gt;<\/span>True<span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">InstrumentIIS<\/span><span style=\"color: #0000ff\">&gt;<\/span>\n          <span style=\"color: #0000ff\">&lt;!--<\/span> <span style=\"color: #008000\">file level data collection<\/span> <span style=\"color: #0000ff\">--&gt;<\/span>\n          <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">ImpactLevel<\/span><span style=\"color: #0000ff\">&gt;<\/span>file<span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">ImpactLevel<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>          <span style=\"color: #0000ff\">&lt;!--<\/span> <span style=\"color: #008000\">any job agent related executable or any other service that the test is using needs to be profiled.<\/span> <span style=\"color: #0000ff\">--&gt;\n<\/span>          <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">ServicesToInstrument<\/span><span style=\"color: #0000ff\">&gt;<\/span>\n            <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">Name<\/span><span style=\"color: #0000ff\">&gt;<\/span>TeamFoundationSshService<span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">Name<\/span><span style=\"color: #0000ff\">&gt;<\/span>\n          <span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">ServicesToInstrument<\/span><span style=\"color: #0000ff\">&gt;\n        &lt;\/<\/span><span style=\"color: #800000\">Configuration<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>      <span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">DataCollector<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>    <span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">DataCollectors<\/span><span style=\"color: #0000ff\">&gt;\n<\/span>  <span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">DataCollectionRunSettings<\/span><span style=\"color: #0000ff\">&gt;\n&lt;\/<\/span><span style=\"color: #800000\">RunSettings<\/span><span style=\"color: #0000ff\">&gt;<\/span><\/span><\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/devops\/accelerated-continuous-testing-with-test-impact-analysis-part-1\/enablingtia_2\/\"><img decoding=\"async\" width=\"927\" height=\"509\" class=\"alignnone size-full wp-image-36655\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/03\/EnablingTIA_2.jpg\" \/><\/a><\/p>\n<h3>Reporting<\/h3>\n<p>TIA is in integrated into existing test reporting at both the summary and details levels, including notification emails.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/report.jpg\"><img decoding=\"async\" width=\"929\" height=\"662\" class=\"alignnone size-full wp-image-28215\" alt=\"report\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/03\/report.jpg\" \/><\/a><\/p>\n<h3>Robust Test Selection<\/h3>\n<p>But why should you trust TIA? How do you know that quality has not been compromised in all of this? To answer that we need to look at 2 aspects:\n(1)\u00a0what are the tests that get automatically selected\n(2)\u00a0policies that can condition test selection.<\/p>\n<p>TIA will look at an incoming commit, and select the set of relevant tests \u2013 these will have 3 components\n<strong>(1)<\/strong> The <strong>existing tests<\/strong> impacted by the incoming commit.\n<strong>(2)<\/strong> Additionally, it will also select <strong>previously failing tests<\/strong> \u2013 if not, then over the course of several commits some earlier failing test case might just get lost \u2026 Therefore, TIA will keep track of tests that failed in the previous build and include them in the selection.\n<strong>(3)<\/strong> It will also include <strong>newly added tests<\/strong> \u2013 what if your commit contains new tests? Such tests could uncover product bugs, right? So, TIA will select newly added tests as well.<\/p>\n<p>Taken together, this complement makes for a robust selection of tests. Additionally, we allow (and recommend) running\u00a0all tests at a configured periodicity.<\/p>\n<h3>Scope<\/h3>\n<p>TIA is presently scoped to the following:<\/p>\n<ul>\n<li>Supported\n<ul>\n<li>TFS 2017 Update 1 onwards and on VSTS<\/li>\n<li>Version 2.* of the Visual Studio Test task in the build definition<\/li>\n<li>Build vNext, with multiple VSTest Tasks<\/li>\n<li>VS2015 Update 3 onwards on the build agent<\/li>\n<li>Local and hosted build agents<\/li>\n<li>CI and in PR workflows<\/li>\n<li>Git, GitHub, External Git, TFVC repos<\/li>\n<li>IIS interactions (over REST, SOAP APIs), using HTTP\/HTTPS protocols<\/li>\n<li>Automated Tests<\/li>\n<li>Single box topology (tests and application must be running on the same machine).<\/li>\n<li>Managed code (any .NET Framework application, any .NET Service)<\/li>\n<\/ul>\n<\/li>\n<li>Not yet supported\n<ul>\n<li>Multi box topology (where the test is exercising an app deployed to a different machine)<\/li>\n<li>Data driven tests<\/li>\n<li>Test Adapter-specific parallel test execution<\/li>\n<li>.NET Core<\/li>\n<li>UWP<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Next post<\/h3>\n<p>We will continue this series in the next post, looking at more details, specifically: manual overrides, repo considerations, using TIA in PR builds, and interaction with Code Coverage. If you would like any other aspect covered in more detail, let us know.<\/p>\n<p>In the meantime, start using TIA! Looking forward to your feedback.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuous Testing in DevOps In older testing strategies, large software changes were tested as a complete product after a so called &#8220;release to QA&#8221;, running almost all tests just before release. We know the downsides to that. On the other hand, DevOps is all about a fast development to delivery pipeline and continuous delivery of [&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":[226,1,252],"tags":[],"class_list":["post-28125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>Continuous Testing in DevOps In older testing strategies, large software changes were tested as a complete product after a so called &#8220;release to QA&#8221;, running almost all tests just before release. We know the downsides to that. On the other hand, DevOps is all about a fast development to delivery pipeline and continuous delivery of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/28125","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=28125"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/28125\/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=28125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=28125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=28125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}