Knowledge Base Article

Code for Tracking Tested App Info On Start Test.

Question

 

I like to know the information about the tested app each test ran on so I wrote up a little code and put it in the OnStartTest Test Engine Event.

 

Answer

 

This will run every time I run a test telling me the tested app info.  This is wonderful for tracking one off test runs and which app version a test passed on and which it failed on.

 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/index.html

https://support.smartbear.com/testcomplete/docs/reference/events/onstarttest.html?sbsearch=OnStartTe...

 

 

 

function EventControl_OnStartTest(Sender)
{
  try
  {    
    Log.AppendFolder("< EventControl_OnStartTest >");
      Log.AppendFolder("Version Information");
        var FileName = "C:\\Program Files (x86)\\Some Folder\\TestedApp.exe";
        var VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo;
        var FileInf = aqFileSystem.GetFileInfo(FileName);
        var HostName = Sys.HostName;
        var dtObj; 
        Log.Message("File Name: " + FileInf.Name);
        Log.Message("File Version: " + VerInfo.FileMajorVersion + "." + VerInfo.FileMinorVersion + "." + VerInfo.FileBuildVersion + "." + VerInfo.FileRevisionVersion);
        dtObj = new Date(FileInf.DateLastModified);
        Log.Message("File Date: " + FileInf.DateLastModified);
        Log.Message("Host Name: " + HostName);
      Log.PopLogFolder();
  }
  catch(err)
  {
    Process.Halt("Exception: EventControl_OnStartTest - " + err.message);  //Stop Test Run.
  }
}
Published 4 years ago
Version 1.0
No CommentsBe the first to comment