Forum Discussion
TanyaYatskovska
10 years agoSmartBear Alumni (Retired)
Hi Jimmy,
There are two ways you can consider:
1. If you are running Test Items, you can extract the name from the caption of the test item element by using regular expressions:
'VBScript
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "-\s(.+)"
regEx.IgnoreCase = True
Set Matches = regEx.Execute(Project.TestItems.Current.ElementToBeRun.Caption)
Log.Message(Matches(0).SubMatches(0))
2. In case of JScript, use methods and properties of the JScript Function object to get the code of the currently executed function. For example, the following method returns the call stack of the currently executed function:
'JScript
function GetStack()
{
var text, fname, parent;
text = "";
parent = GetStack["caller"];
do {
fname = parent["toString"]()["match"](/function (\w*)/)[1];
text += fname + "\r\n";
parent = parent["caller"];
} while (parent);
return aqString["Trim"](text);
}
To get the name of the currently executed routine, call GetStack from it.
There are two ways you can consider:
1. If you are running Test Items, you can extract the name from the caption of the test item element by using regular expressions:
'VBScript
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "-\s(.+)"
regEx.IgnoreCase = True
Set Matches = regEx.Execute(Project.TestItems.Current.ElementToBeRun.Caption)
Log.Message(Matches(0).SubMatches(0))
2. In case of JScript, use methods and properties of the JScript Function object to get the code of the currently executed function. For example, the following method returns the call stack of the currently executed function:
'JScript
function GetStack()
{
var text, fname, parent;
text = "";
parent = GetStack["caller"];
do {
fname = parent["toString"]()["match"](/function (\w*)/)[1];
text += fname + "\r\n";
parent = parent["caller"];
} while (parent);
return aqString["Trim"](text);
}
To get the name of the currently executed routine, call GetStack from it.
Related Content
- 13 years agojyothi_priya
- 2 years agohinabatooq
- 3 years agoHenrikHL
- 2 years agobknutson
Recent Discussions
- 2 days agoMW_Didata