Here's a function that I developed. It forces TestComplete to create a test log.
As far as I can tell....
Testcomplete will not generate a log before finishing a test or pausing a test. Without having a log available, finding the current keyword test name is difficult - TestComplete doesn't have a built-in method - Asking TC to save a log forces it to generate a log - the log will contain the current test name (really whatever caused the runner to start. It could be a keywork test, test item, script, etc.).
Once you have create the file from a log export, you can open the file and extract the name that will appear in the test log.
Function GetCurrentTestName()
dim temp
dim logfolderPath
dim logindexFile
dim indexPathFile
dim templogPath
dim templogfile
dim templogText
'delete previous folder
Call aqFileSystem.DeleteFolder(Project.ConfigPath + "\ExportedLog", true)
'testcomplete will not generate a log before finishing a test or pausing a test.
'Without having a log available, finding the current keyword test name is
'difficult - TestComplete doesn't have a built-in method - Asking TC to
'save a log forces it to generate a log - the log will contain the
'current test name
log.SaveResultsAs Project.ConfigPath + "ExportedLog\templog.xml", IsXML
Set templogfile = aqFile.OpenTextFile(Project.ConfigPath + "ExportedLog\templog.xml", aqFile.faRead, aqFile.ctANSI)
templogText = templogfile.ReadAll
templogfile.Close
'<Prp name="test type" type="S" value="Log_Index_check7777"/>
dim iFind1
dim iFind2
dim iFind3
dim sText1
dim sText2
sText1 = "<Prp name=" + chr(34) + "test type" + chr(34) + "type=" + chr(34) + "S" + chr(34) + ""
iFind1 = InStr(templogText, "test type")
sText2 = "value="
iFind2 = InStr(iFind1+1, templogText, sText2)
iFind3 = InStr(iFind2+1, templogText, "/>")
temp = Mid(templogText,iFind2 + len(sText2)+1, iFind3 - iFind2 - len(sText2)-2)
log.message "current test name: '" + Mid(templogText,iFind2 + len(sText2)+1, iFind3 - iFind2 - len(sText2)-2) + "'"
GetCurrentTestName = temp
End Function
Related Content
- 10 years ago
- 7 years ago
- 9 years ago