How to call a step in test_A from test_B ?

4 posts, 0 answers
  1. HoangPham
    HoangPham avatar
    6 posts
    Member since:
    Oct 2013

    Posted 08 Nov 2013 Link to this post

    Hi all,

    I have some classes as below (see in Code Block), and my questions are:

    1. How can i create some more test methods in the MainWindowUnitTest test class with there are only several (not all) CodedStep functions invoked in each test method ?

    2. How can I create a new one more test methods in the MainWindowUnitTest test class with several functions in the MainWindow class and one (or more) functions created in the  LoginDashboard class ? ( ex: the new test method in MainWindowUnitTest class is MainWindow_TestMethod_2(), and functions invoked in this new method are: MainWindow_CodedStep, MainWindow_ManualFunction_01 , LoginDashboard_CodedStep1 and  LoginDashboard_ManualFunction1  )

    namespace TestingOnDashboard_01
    {
        public class MainWindow : BaseWebAiiTest
        {
            [CodedStep(@"Open 'ManagementCombobox' drop down.")]
            public void MainWindow_CodedStep()
            {
                // Open 'ManagementCombobox' drop down.
                Applications.HPhamDashboardWpfShellexe.HPham_Dashboard.ManagementCombobox.OpenDropDown(true);
            }
     
            [CodedStep(@"Wait for Exists 'btn_LogOutDashboard'")]
            public void MainWindow_CodedStep1()
            {
                // Wait for Exists 'btn_LogOutDashboard'
                Applications.HPhamDashboardWpfShellexe.HPham_Dashboard.btn_LogOutDashboard.Wait.ForExists(30000);
            }
             
            public bool MainWindow_ManualFunction_01()
            {
                ...
            }
             
            public int MainWindow_ManualFunction_02()
            {
                ...
            }
        }
    }
    ----------
    namespace TestingOnDashboard_01
    {
        [TestClass]
        public class MainWindowUnitTest : BaseWpfTest
        {
            [TestMethod()]
            public void MainWindow()
            {
                 
            }
        }
    }
    ------------------------------------------
    namespace TestingOnDashboard_01
    {
        public class LoginDashboard : BaseWebAiiTest
        {
            [CodedStep(@"LeftClick on Item0Textboxview")]
            public void LoginDashboard_CodedStep()
            {
                // LeftClick on Item0Textboxview
                Applications.HPhamDashboardWpfShellexe.EmptyTitleWindow.Item0Textboxview.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 35, 27, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            }
     
            [CodedStep(@"Type 'hpham' into UserNameTextBoxTextbox")]
            public void LoginDashboard_CodedStep1()
            {
                // Type 'hpham' into UserNameTextBoxTextbox
                Applications.HPhamDashboardWpfShellexe.EmptyTitleWindow.UserNameTextBoxTextbox.SetText(true, "hpham", 10, 100, false);
            }
             
            public bool LoginDashboard_ManualFunction1()
            {
                ....
            }
        }
    }
    ------------
    namespace TestingOnDashboard_01
    {
        [TestClass]
        public class LoginDashboardUnitTest : BaseWpfTest
        {
            [TestMethod()]
            public void LoginDashboard()
            {
            }
        }
    }

    Thanks & Best regards,
    Hoang Pham.
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 14 Nov 2013 Link to this post

    Hi Hoang,

    Thank you for contacting us.

    Unfortunately I am not sure if I understand you correctly. 

    Regarding the first question:

    You can create more test methods by copying the already existing test method:   

    [CodedStep(@"Wait for Exists 'btn_LogOutDashboard'")]
            public void NewMethod()
            {
               
            }

    You just need to change the name.

    Regarding the second question:

    Do you want to access a test method from a different class?

    There are two options how to achieve this:

    1. You should create an instance of the other class and then via this instance you can access the methods in it:

    WebTest1 firstTest = new WebTest1();
    firstTest.WebTest1_CodedStep();

    2. If you would like to create global variables or functions in Test Studio Standalone version that are accessible from all the tests within the test project, you can create a utility class. This class will contain the intended functions or variables.

    Let me know if I am missing something.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. HoangPham
    HoangPham avatar
    6 posts
    Member since:
    Oct 2013

    Posted 16 Nov 2013 Link to this post

    Hi Boyan,

    This issue was resolved.

    Thank Boyan a lot !
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 18 Nov 2013 Link to this post

    Hello Hoang,

    I am glad to hear that.

    If you need additional assistance, please do not hesitate to contact us. 

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!