Forum Discussion
alevans4
14 years agoContributor
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.
Related Content
- 2 years ago
- 11 months ago
- 12 months ago
Recent Discussions
- 11 hours ago
- 2 days ago