Knowledge Share

Knowledge is NOT Power IMPLEMENTATION of knowledge is Power!!!
 
HomePortalGalleryCalendarFAQRegisterUsergroupsLog in

Share | 
 

 purpose of Test Clean up

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin


Posts : 141
Points : 407
Reputation : 0
Join date : 2007-12-29
Location : Chennai

PostSubject: purpose of Test Clean up   Wed 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
http://knowledgeshare.forumotion.com
 
purpose of Test Clean up
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» How to move my selenium test cases from Rc to Grid
» Test javascript Calendar
» How to create a test suite in Selenium?
» 'Play Current Test Case' button not support to Ruby language.
» What is the use of Selenium Core and Selenium Test Manager ? (N-Unit Procedures in VS 2010)

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