{"id":3963,"date":"2012-11-08T03:14:00","date_gmt":"2012-11-08T03:14:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2012\/11\/08\/coded-ui-test-why-does-application-close-after-each-test-in-visual-studio-2012\/"},"modified":"2022-07-21T06:50:17","modified_gmt":"2022-07-21T14:50:17","slug":"coded-ui-test-why-does-application-close-after-each-test-in-visual-studio-2012","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/coded-ui-test-why-does-application-close-after-each-test-in-visual-studio-2012\/","title":{"rendered":"Coded UI Test: Why does application close after each test in Visual Studio 2012?"},"content":{"rendered":"<p><span style=\"font-family: Calibri;font-size: small\">\u00a0<\/span><span style=\"font-size: small\"><span style=\"font-family: Calibri\">In Visual Studio 2010 SP1, Coded UI Test added a flag <strong><em>CloseOnPlaybackCleanup<\/em><\/strong> to ApplicationUnderTest class. For cases where an application is launched during test run, this flag helps determine whether to close the application under test after test is over.\u00a0<\/span><\/span><span style=\"font-size: small\"><span style=\"font-family: Calibri\"> Default value for the flag\u00a0was set to <strong>true\u00a0<\/strong>(closes the application)\u00a0as it is not advisable to re-use resources from other test cases.\u00a0But although this flag was introduced, the Coded UI engine was not honoring the value due to a bug that we have fixed. As a result, all applications would continue to run even after the flag is set to true in VS 2010 SP1<\/span><\/span><\/p>\n<p><span style=\"font-size: small\"><span style=\"font-family: Calibri\">Since the bug is fixed in Visual Studio 2012 users will see<\/span><\/span><span style=\"font-size: small\"><span style=\"font-family: Calibri\">\u00a0 BrowserWindow \/ ApplicationUnderTest is getting closed after each test case if they don&#8217;t have CloseOnPlaybackCleanup flag set to false.<\/span><\/span>\u00a0<\/p>\n<p><span style=\"font-size: small\"><span style=\"font-family: Calibri\">\u00a0If you want to reuse any application instance launched in another test case, you have to assign CloseOnPlaybackCleanup flag to <strong>false<\/strong> for ApplicationUnderTest \/ BrowserWindow object. <\/span><\/span><\/p>\n<p><span style=\"font-size: small\"><span style=\"font-family: Calibri\">Please refer to sample code as below. If you run all these three tests together, BrowserWindow will be launched only once, remaining other tests will use existing browser instance from the previous test. If you run each test individually, then each test case will close the browser at the end of the run.<\/span><\/span><\/p>\n<p>\u00a0<\/p>\n<p><span style=\"font-family: Calibri;font-size: small\">\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2012\/11\/4527.CodeScreenshot.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2012\/11\/4527.CodeScreenshot.png\" alt=\"\" border=\"0\" \/><\/a><\/span><\/p>\n<p>\u00a0<span style=\"font-size: small\"><span style=\"font-family: Calibri\">The same principle is applied with running tests using Command Line. If you are running tests altogether, the Application Under test will remain open in between tests in case CloseOnPlaybackCleanup is set to false. Once the run is over, all application instances which were launched during the run are closed. <\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0In Visual Studio 2010 SP1, Coded UI Test added a flag CloseOnPlaybackCleanup to ApplicationUnderTest class. For cases where an application is launched during test run, this flag helps determine whether to close the application under test after test is over.\u00a0 Default value for the flag\u00a0was set to true\u00a0(closes the application)\u00a0as it is not advisable to [&hellip;]<\/p>\n","protected":false},"author":101,"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-3963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>\u00a0In Visual Studio 2010 SP1, Coded UI Test added a flag CloseOnPlaybackCleanup to ApplicationUnderTest class. For cases where an application is launched during test run, this flag helps determine whether to close the application under test after test is over.\u00a0 Default value for the flag\u00a0was set to true\u00a0(closes the application)\u00a0as it is not advisable to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/3963","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\/101"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=3963"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/3963\/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=3963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=3963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=3963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}