If you're working with PURE JavaScript and no keyword tests, you can do this (just found this myself with a quick Google search):
function getCaller(){
if (getCaller.caller != null) {
Log.Message('My caller was ' + getCaller.caller.name)
}
}
function theCaller(){
getCaller();
}
It's really pretty cool.
However, a KeywordTest is not a JavaScript function... so it doesn't have all those nifty properties that will tell you who called the script function. The above "getCaller" function, if called from within a keyword test, won't return the keyword test name... in fact, the log message won't even execute because "caller" is null.
This is where something like what we have in our framework works well. The data structures we have in place that do the test execution actually store the names of each keyword test to be executed along with several other properties in an object within a larger array. When we get to a test to run, we put that individual element from the array into a "CurrentTestCase" globally scoped variable. Then, at any point when that test case is running, we can go to that variable and retrieve any information we want from the test case including the name, what parameters are used, what it's current status (PASS/FAIL) is, etc.
This is what Project Items do for you by giving you a built in feature of TestComplete that allows you to get some information about the test item. So, if each of your keyword tests has a corresponding test item that does the execution, then the Project.TestItems.Current.Name will help you to determine what is currently being executed.
As for the feature request that I submitted... that's kind of the reverse... more on the lines of, within a script function, be able to use just a string to trigger what keyword test to execute... and our dear friend HKosova gave us a fabulous workaround for that.
function runKeywordTest(testName){
KeywordTests[testName].Run()
}