Hi,
I am currently running distributed tests with the following hierarchy
- Individual VB Scripts with a list of sub routines
- A Driver VB Script which runs all the sub routines from 1.
- A Job which contains a Task to run the Driver VB Script
- This Job is then added to the project explorer as a test item
- A Scheduled Task runs the Project
I have a function that will output the CPU & Memory usage for 2 exes as to a csv file.
I want to call this function from each individual sub routine (in 1. above) as i want output the CPU & Mem usage.
I have tried the "Project.TestItems.Current.ElementToBeRun.Caption" but with no luck. I get :
Object required: 'Project.TestItems.Current'
My code is below. My question is how can i get down to unit level in order to get the sub routine name to log to the file.
Sub CPU_Mem_Usage
Dim VerFileName, VerInfo, TestItems, tName
VerFileName = "\\MyPC1\c\program files\MyExe\MyExe.exe"
Set VerInfo = aqFileSystem.GetFileInfo(VerFileName).VersionInfo
sFolder = "\\Server1\TestComplete\FutaTill\Results\"
aqFileSystem.CreateFolder(sFolder)
sPath = sFolder & "\Build_"&VerInfo.FileFullVersion&"\Build_"&VerInfo.FileFullVersion&".csv"
tName = Project.TestItems.Current.ElementToBeRun.Caption
If Not aqFile.Exists(sPath) Then
Call aqFile.Create(sPath)
Call aqFile.WriteToTextFile(sPath, "CPU & Memory Usage Statistics for My Exe Build Version " & VerInfo & vbCrlf , aqFile.ctANSI, False)
Call aqFile.WriteToTextFile(sPath, "Test Date & Time: " & aqDateTime.Now & vbCrlf , aqFile.ctANSI, False)
Call aqFile.WriteToTextFile(sPath, "" & vbCrlf , aqFile.ctANSI, False)
Call aqFile.WriteToTextFile(sPath, "Time, Script Name,,,,,,,MyExe, CPU (%), Mem Usage (K),, MyExe2, CPU (%), Mem Usage (K)" & vbCrlf , aqFile.ctANSI, False)
Call aqFile.WriteToTextFile(sPath, "*****************************************************************************************************************************************" & vbCrlf , aqFile.ctANSI, False)
End If
Call aqFile.WriteToTextFile(sPath, aqDateTime.Time & "," & tName & ",,,,,,,," & Sys.Process("MyExe").CPUUsage & "," & Sys.Process("MyExe").MemUsage & "," & ",," & Sys.Process("MyExe2").CPUUsage & "," & Sys.Process("MyExe2").MemUsage & vbCrlf , aqFile.ctANSI, False)
End Sub
All help greatly appreciated
Thanks,
Jimmy