Knowledge Share
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Knowledge Share

Knowledge is NOT Power IMPLEMENTATION of knowledge is Power!!!
 
HomePortalGalleryLatest imagesRegisterLog in

 

 purpose of Test Clean up

Go down 
AuthorMessage
Admin
Admin



Posts : 142
Points : 59634446
Reputation : 0
Join date : 2007-12-29
Location : Chennai

purpose of Test Clean up Empty
PostSubject: purpose of Test Clean up   purpose of Test Clean up Icon_minitimeWed Jun 10, 2015 10:31 am

Test Cleanup is code that runs after each test.
Test cleanup is declared inside the same class where your tests are declared. Also any assertions you have that go in TestCleanup can fail the test. This is very useful if you have values you check for each test in the same location that could potentially fail the test.
[TestCleanup]
      public void CleanUp()
      {
         AppManager.CheckForHandledExceptions();
      }
Here are the important events to consider:
[ClassInitialize]
      public static void Init(TestContext testContext)
      {
         //Runs before any test is run in the class - imo not that useful.
      }
 
[TestInitialize]
      public void Init()
      {
         //Runs just prior to running a test very useful.
      }
Mostly I use TestInitialize to reset the uimap between tests, otherwise control references can go stale.
Next what runs at the end, once all the tests in your assembly have run (very good for checking for unhandled exceptions or maybe shutting down the application).
So if you run 100 tests via MTM, after the last one is finished, AssemblyCleaup will run, also note this method is a bit special it is declared once per assembly, in it's own class with the [CodedUITest] attribute on the class.
[CodedUITest]
   public class TestRunCleanup
   {
      [AssemblyCleanup()]
      public static void AssemblyCleanup()
      {
         AppManager.CloseApplicationUnderTest();
      }
   }
Back to top Go down
https://knowledgeshare.forumotion.com
 
purpose of Test Clean up
Back to top 
Page 1 of 1
 Similar topics
-
» Automatic email after Coded UI Test execution
» Creating Coded UI Test
» Coded UI Test Tools
» Difference between QTP, Selenium and Silk test

Permissions in this forum:You cannot reply to topics in this forum
Knowledge Share :: Testing :: Automation :: VSTS :: CODED UI-
Jump to: