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
Is there a way to return the name of the current sub routine or function?
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've added your votes. Thanks!
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a System function for the Routine Name would be nice. We'd also Need a System function for the module Name, of course.
I'd also add my vote.
So far, You could use code templates for vbs modules and routines, which contain predefined constants for the element names, e.g. for a module:
Option Explicit
' ModulKommentar
Const mcModul = "Modulname."
or for a Routine
Function |( _
Par1, _
Par2 _
)
' KommentarFunktion
Const cRoutine = "NameFunktion"
Dim Ergebnis
NameFunktion = Ergebnis
End Function
As a result, I can use the names in the log, e.g.
Log.Checkpoint "Tabelle Abbruch abgebrochen", mcModul & cRoutine
Regards,
Manfred
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I've added your votes.
Manfred, thanks for sharing your solution.
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please add my vote as well!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
+1 for this feature.
Kindly add my vote too.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for your requests! Now, we have a special place in the Community where our users can submit their ideas or vote for the ideas they like. I’ve found a similar idea that has already been submitted. You can vote it up.
TestComplete’s PO monitors this forum on a regular basis, and uses this information for development planning.
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am also trying to figure out a way to know the current script name. We are launching TestExecute with Bamboo using command line. I think we can use
BuiltIn.ParamStr
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For JavaScript, I found the following workaround. Maybe it will help others.
I create a try-catch block. Within the try I provoke an exception, this one I catch-up with the catch and read-out the function name in the stack.
Note: this also works across several units -> USEUNIT
function getCaller(){ let arrStackLines = []; try{ throw new Error("throw a error to get the stack"); }catch(objE){ arrStackLines = objE.stack.split("\n"); } let strLine = arrStackLines[arrStackLines.length -1]; let intStart = strLine.indexOf("at ") + 3; let intEnd = strLine.indexOf("(<"); Log.Message(strLine.substring(intStart, intEnd)); }
Btw. please add my vote..:-)
Best regards
meinTest GmbH
SmartBear preferred value-added Service
Provider in the DACH region

- « Previous
- Next »
- « Previous
- Next »