Is there a way to return the name of the current sub routine or function?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2010
04:56 PM
08-11-2010
04:56 PM
Is there a way to return the name of the current sub routine or function?
Hi All,
Is there a way to return the name of the current sub routine or function that is being run. It would be nice to enter into the log.
I am currently coding in VB Script.
I assume there is no way to do it using VB script but is there a TestComplete inbuilt function?
Thanks heaps,
Adrian
Is there a way to return the name of the current sub routine or function that is being run. It would be nice to enter into the log.
I am currently coding in VB Script.
I assume there is no way to do it using VB script but is there a TestComplete inbuilt function?
Thanks heaps,
Adrian
29 REPLIES 29
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2010
08:06 PM
08-11-2010
08:06 PM
Hi,
There is no built-in way to do this. However, we have an appropriate suggestion to implement such an ability, and your post has increased its rating.
There is no built-in way to do this. However, we have an appropriate suggestion to implement such an ability, and your post has increased its rating.
------
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2010
07:37 PM
12-08-2010
07:37 PM
I add my voice for this feature.
We make the world a better place!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2010
06:49 PM
12-09-2010
06:49 PM
Hi,
I've increased the suggestion's rating.
I've increased the suggestion's rating.
------
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011
12:47 PM
02-22-2011
12:47 PM
Can I add another vote?
Thanks.
Thanks.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011
07:11 PM
02-22-2011
07:11 PM
Hi,
Your vote is added.
Your vote is added.
------
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2011
10:58 PM
08-16-2011
10:58 PM
my vote too 😞
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2011
01:20 AM
08-17-2011
01:20 AM
ACTUALLY... if you're using JScript, you can use the technique discussed in the following article:
http://blog.smartbear.com/post/11-02-16/improving-traceability-in-testcomplete-logs/
Every function you create, then, add in the code as the first line of the function
You then make sure you have a project variable set as a string type with the default value set to
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
http://blog.smartbear.com/post/11-02-16/improving-traceability-in-testcomplete-logs/
Every function you create, then, add in the code as the first line of the function
eval(Project.Variables.functionEnter)
You then make sure you have a project variable set as a string type with the default value set to
var functionName = eval ('arguments.callee.toString()');var parameters = eval ('arguments.callee.toString()');
var message = '';
functionName = functionName.substr('function '.length);
functionName = functionName.substr(0, functionName.indexOf('('));
parameters = parameters.substr (parameters.indexOf ('(') + 1);
parameters = parameters.substr (0, parameters.indexOf (')'));
parameters = parameters.replace (/\r\n|\n/gm, ' ');
parameters = parameters.split(/,\s?/);
for (var i = 0; i < parameters.length; i++)
{
message += 'Parameter [' + parameters + '] : ';
message += typeof arguments + '\n';
if (arguments === undefined)
{
message += '\n';
}
else if (typeof arguments === "string")
{
message += '\t"' + arguments + '"\n\n';
}
else
{
message += '\t' + arguments + '\n\n';
}
}
Log.Message ('Entering ' + functionName, message);
This works like a charm and I've started using this extensively in my own code work.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2011
12:49 AM
08-19-2011
12:49 AM
Hi Regalo,
Done. The suggestion's rating is increased.
Best regards,
Alexey
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Done. The suggestion's rating is increased.
Best regards,
Alexey
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2011
07:17 PM
08-25-2011
07:17 PM
ACTUALLY... if you're using JScript, you can use the technique discussed in the following article:
http://blog.smartbear.com/post/11-02-16/improving-traceability-in-testcomplete-logs/
I'm a little confused with that blog post. Specifically where he says, "JScript doesn’t have some sort of macro expand or #include feature to
aid in calling this code, but we can use a feature that TestComplete
does have—project variables." While true, Jscript doesn't have includes, TestComplete definitely does (USEUNIT), unless you took it away in v8 since we're still on v7. And if you're able to use project variables, you're definitely also able to use includes since you're running in TestComplete. So, just have standard include script, or multiple depending on your needs.
Add this somewhere in your script (or like I do in a standard include):
Function.prototype.name = function() {
var m = this.toString().match(/^\s*function\s+([^\s\(]+)/);
return m ? m[1] : "";
}
then in whatever test you run:
function test()
{
Log.Message(argument.callee.name());
}
If you're squirrelly about modifying the Function prototype, could just drop a generic function:
function getFunctionName(fn)
{
var m = fn.toString().match(/^\s*function\s+([^\s\(]+)/);
return m ? m[1] : "";
}
and then
function test()
{
Log.Message(getFunctionName(argument.callee));
}
Adding in the extra parameter info would be fairly trivial if you wanted to drop in something like a Function.prototype.logFunctionCall or something.
