Forum Discussion
Here is a screenshot of what I am doing to show the setup on how the test is called: (I also do something similar to call some scripts too.)
You can see I have a keyword test which takes in 9 parameter values, in order to make a backup of the data I want to preserve. Note that the 7th parameter is a Code Expression, which refers to a variable specific to the test being executed in the test "CSA_Maint_Copy_CSA_and_Verify_Default_Values_Flow"
The Keyword test which I am calling is a generic method which I reuse across many tests, so only the parameters values it receives change.
The problem is... when I copy (control-c) the step which calls the generic method, and paste it in to another test, I then have to manually update the test name from "CSA_Maint_Copy_CSA_and_Verify_Default_Values_Flow" to reflect the new test name that I have created (let's say "CSA_Maint_Copy_CSA_and_Verify_Employees_Flow"). If there was a "currenttest" or "this.test" reference that I could use instead of the test name, then it would save the manual editing of these parameters with each new test created.
Does this help? https://support.smartbear.com/testcomplete/docs/testing-with/running/get-test-name.html
- scottroutesmart3 months agoContributor
I have tried to work with that method also, but haven't been successful. The suggestions that TC gives doesn't offer the Parameters or Variables to be appended to Project.TestItems.Current.Name
When I try use something along those lines, it throws an Exception during runtime for either parameters or variables if you try to setup similar to this...
"Project.TestItems.Current.Name.Parameters.StationNumber"Apparently, the Current.Name method doesn't extend to also allow for the use of the test's Parameters or Variables...
- Marsha_R3 months ago
Champion Level 3
The examples under Get Test Case Name will show you how to get the name. Then you can do something like this or whatever you need.
MyNewVariable = aqTestCase.CurrentTestCase.Name + "- " + MyParameterName
- scottroutesmart3 months agoContributor
For anyone else who is watching this thread and may want to do something similar in JScript, Marsha gave me enough info that I was able to put together this single line which can be used as the Code parameter I needed for the keyword test I am calling (from the top level test in my Execution Plan)...
eval(aqString.Concat(aqString.Replace(Project.TestItems.Current.ElementToBeRun.Caption, ' - ', '.'), '.Parameters.StationNumber')) + " - COPY"
I am sure that someone can probably come up with something more concise, but that was the best I could do in a short time using the functions I could find within the online documentation. If you have anything better, feel free to share.