This is a migrated thread and some comments may be shown as answers.

How to call a step in test_A from test_B ?

3 Answers 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
HoangPham
Top achievements
Rank 1
HoangPham asked on 08 Nov 2013, 07:36 PM
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.

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 14 Nov 2013, 09:24 AM
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
0
HoangPham
Top achievements
Rank 1
answered on 16 Nov 2013, 05:40 PM
Hi Boyan,

This issue was resolved.

Thank Boyan a lot !
0
Boyan Boev
Telerik team
answered on 18 Nov 2013, 02:50 PM
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
Tags
General Discussions
Asked by
HoangPham
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
HoangPham
Top achievements
Rank 1
Share this question
or