Object creation while calling methods from another class.

4 posts, 0 answers
  1. SD
    SD avatar
    62 posts
    Member since:
    Apr 2010

    Posted 21 Jun 2010 Link to this post

    Hi Nelson (Thought I'd address you as you're familiar with the issue...;-))

    As you recall, I'm calling helper methods from another Class the resides in another file from my [Test] and that's working well. 
    The thing is, I don't want to create a large number of objects each for each test as I'm doing now (See below)...
    Placing the new object statements under the class (Meaning outside the  [Test])  does not work either...Any ideas ? 

      [Test] 
                public void test_01() 
                { 
                    Users Users = new Users(Manager); 
                    Navigate Navigate = new Navigate(Manager); 
                    Generic Generic = new Generic(Manager); 
                    Register_App Register_App = new Register_App(Manager); 
                    //-------------- 
                    Navigate.Navigate_Basic_LogIn("tester38"); 
                } 

    Ta, 
    SD. 
  2. Missing user
    Missing user avatar

    Posted 23 Jun 2010 Link to this post

    Hello SD,

    I'm not sure I exactly remember what is happening with this scenario, but I would think you can try adding static class helpers for some functionality. Other than that, I would need a bit more context of what the code you posted is doing.

    And are you doing a large number of dynamic object creation or are the objects manipulating alot of different test resources(ie browsers, Desktop, etc.)?
     
    If your doing explicit object creation like in the code posted below, I would not think that this would be too resource intensive and degrade performance.

    Sincerely,
    Nelson Sin
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. SD
    SD avatar
    62 posts
    Member since:
    Apr 2010

    Posted 24 Jun 2010 Link to this post

    Hi Nelson,

    I fully agree to that. Explicitly creating those objects should not have any effect on performance.  
    However, it is essential to maintain code clarity as I'm creating a very large number of test and in most likelihood, 
    almost all use those objects to use help methods. 

    Here's what I'm doing: 
        [Test] 
                public void test_01() 
                { 
                    Users Users = new Users(Manager); 
                    Navigate Navigate = new Navigate(Manager); 
                    Generic Generic = new Generic(Manager); 
                    Register_App Register_App = new Register_App(Manager); 
                    //-------------------- 
                    Navigate.Navigate_Basic_LogIn(Users.MyUser); 
                 } 
    and the helper.....
    public class Navigate : BaseTest  
        {  
            private Manager _manager = null;  
     
            private new Manager Manager  
            {  
                set 
                {  
                    _manager = value;  
                }  
         
                get 
                {  
                    return _manager;  
                }  
            }  
         
            public Navigate(Manager m)  
            {  
                Manager = m;  
            }      
            //************************************************** 
            // Login 
            //************************************************** 
            public void Navigate_Basic_LogIn (String user)  
            { 
              Manager.LaunchNewBrowser(Settings.Current.DefaultBrowser); 
              Manager.SetNewBrowserTracking(true); 
              Manager.ActiveBrowser.NavigateTo(Manager.Settings.BaseUrl); 
              Manager.ActiveBrowser.WaitUntilReady(); 
            } 

    So instead of creating the objects for every test, I thought it would be possible to create at the class level. Does not seem to be working for me...

    Ta 




  4. Missing user
    Missing user avatar

    Posted 29 Jun 2010 Link to this post

    Hi again SD,

    Based on your Navigate class, are you sure you need to create objects every time you need to use the methods?

    I remember the 'new' Manager code, but since it doesn't seem like you are extending any functionality for BaseTest, it looks like you can at least have Navigate as a static class and method that just accepts the main Manager as an argument.

    If you were creating separate tests using the VSUnit Template that would need explicit setup/teardown and use them interchangeably in other VSUnit Template tests, then you would need to create separate test object instances.

    Kind regards,
    Nelson
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top