ali_jafer
11 years agoOccasional Contributor
Checking for existence of a Script Unit and functions/subs defined in it
Suppose I am getteing name of Script Unit and any function defined in it as input from an external data source, if I want to determine, whether this particular Script Unit and function is part of current TestComplete project or not.... is it possible via any scripting techinque (any TestComplet feature or language feature)
I want to acheive something like below
Example:
---
strScriptUnit= get name of function from excel test data sheet
strFunction= get name of function from excel test data sheet
IF strScriptUnit belongs to current Project and strFunction bleongs to strScriptUnit THEN
Runner.CallMethod(strScriptUnit &"."&strFunction,[parmlist...])
ELSE
Log.Message "Non existent Script Unit or Function"
END IF
----
Can we achieve Bold check applied in Pseude Code?
thanks
I want to acheive something like below
Example:
---
strScriptUnit= get name of function from excel test data sheet
strFunction= get name of function from excel test data sheet
IF strScriptUnit belongs to current Project and strFunction bleongs to strScriptUnit THEN
Runner.CallMethod(strScriptUnit &"."&strFunction,[parmlist...])
ELSE
Log.Message "Non existent Script Unit or Function"
END IF
----
Can we achieve Bold check applied in Pseude Code?
thanks
Hi Ali,
You can use the following function:
//JScript
function FunctionExists(UnitName, FunctionName)
{
var oTC = Sys.OleObject("TestComplete.TestCompleteApplication");
var strProjectName = /\\([^\\]+).mds$/.exec(Project.FileName)[1];
var colFunctions = oTC.Integration.ProjectRoutinesIterator(strProjectName);
colFunctions.Reset();
var oFunc;
while (colFunctions.HasNext())
{
oFunc = colFunctions.Next;
if ((oFunc.UnitName == UnitName) && (oFunc.Name == FunctionName))
return true;
}
return false;
}