Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 20755

Get VB Script Unit Name from Distributed Testing setup

$
0
0

Hi,

 

I am currently running distributed tests with the following hierarchy

  1. Individual VB Scripts with a list of sub routines
  2. A Driver VB Script which runs all the sub routines from 1.
  3. A Job which contains a Task to run the Driver VB Script
  4. This Job is then added to the project explorer as a test item
  5. 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 :

 
VBScript runtime error.
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

 


Viewing all articles
Browse latest Browse all 20755

Trending Articles