Actions help to divide the test into small parts and increase reusability. When we create a new Test , an action will be attached by default with the Test. A test is comprised of one or more Actions.
For Example, suppose we want to create a Test for a Banking application. We need to automate the functionalities like ‘Creating a customer account’,’Adding beneficiary’,’Transferring amount’ etc.
So, We can create a Test with 3 Actions which will cover all those 3 scenarios respectively.
There are 3 types of calls to Actions.
1. Call to new Action
2. Call to copy of Action
3. Call to Existing Action
We can add Actions to the test from 3 locations.
1. Right click on Test in solution explorer –> Add
2. Right click in the Expert view –> Action
3. From Design Tab in menu
Call to new Action: It will add a new Action into the Test. We may provide the Action name and description if required. By default, this action will be reusable. That means it can be called from inside the Test and from other Test as well.You can see that a check-box ‘Reusable Action’ is checked. If you un-check this, then test can be called from its own Test only, not from other test.
You need to select the location to add the Action in the Test.There are 2 options.
1. At the end of the Test: Action will be added at the end of the Test.
2. After the current step: A RunAction call will be added into the current Action from where it is called.
Once you select this option,check box will become disable because Its parent,where it is being called, already reusable.
RunAction “Action2”, oneIteration
Call to Copy of a Action: When you insert a call to a copy of an action into a test, the original action will be copied with all the resources attached to it like object repository,checkpoint,parametrization etc. If original action is reusable, then copied action will also be reusable. The key point to note here is that if you make any changes to this copied action , those changes will not be reflected to the original action.
Call to Existing Action: You can use this option for calling the actions which are stored with the current test(local action) or any other test(external action). It will ask you to select the location where you have stored the action and it will be attached with the current test. But key point to note here is that it will be called in a read only mode. That means if you want to modify any thing into external action , then you have to open that particular action explicitly.