Forum Discussion

ahmed_daniel's avatar
ahmed_daniel
Occasional Contributor
10 years ago
Solved

Is there a way to find out how a test was started by TestComplete or TestExecute?

Hi,

 

I want to know if there is way I could check if the automated test is started by TestComplete or TestExecute from script within tests?

If TestCompelte starts I want certain values for project variables. Whereas if TestExecute was used to run the tests then I want certain different values to be stored in the project variables. These values are used to manipulate other tests along the way.

 

I use TestExecute to run on my test machines and TestComplete on my host mostly for writing new tests.

 

Regards,

Daniel

  • ghuff2's avatar
    ghuff2
    10 years ago

    You can try using BuiltIn.ParamStr(0) function to grab the command line executable. That function grabs the command line args like a Java or C-based program, so calling it at index 0 gives the executable string. You'd then have to play around with the string to see if it contains TestComplete.exe or TestExecute.exe. So for example if you launch with TestComplete the BuiltIn.ParamStr(0) will be the string 'C:\Program Files\SmartBear\TestComplete 11\Bin\TestComplete.exe' (or wherever your TestComplete executables is installed.

     

    Here's one way you might do it in python:

     

     

    command_str = BuiltIn.ParamStr(0)
    
    if command_str.find('TestComplete.exe') != -1:
      #Set values for TestComplete
    else:
      #Set values for TestExecute

     

    Or whatever best method you think.

     

  • Another way:

    var testrunner = Sys.FindId(Win32API.GetCurrentProcessId()).ProcessName;
    // "TestComplete" or "TestExecute"

6 Replies

  • Another way:

    var testrunner = Sys.FindId(Win32API.GetCurrentProcessId()).ProcessName;
    // "TestComplete" or "TestExecute"
    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      Knew there had to be other methods! These could come in handy so I'm bookmarking this one.

       

      With both installed, my method was never going to work.

      • ahmed_daniel's avatar
        ahmed_daniel
        Occasional Contributor

        Thank you guys, Both these solutions solve my issue :)

  • Maybe a slightly roundabout method, but if the execute machines only contain TestExecute and your development machine only contains TestComplete, you should be able to check for the presence of the folders or the exe for each? And then set a global variable or call a routine based on the result of that check?

     

    I do something similar to determine whether a run is being done on a remote networked machine.

     

    All installs on remote machines, I also add a dummy folder to the root of the C: drive. This is effectively a flag which tells TestExecute it's running on a remote machine and to write it's results to a network drive rather than the local one.

     

    If running on my local machine, that folder is not present and results are written to the local hard drive.

     

    Works fine for me.

    • ahmed_daniel's avatar
      ahmed_daniel
      Occasional Contributor

       

      Hi Colin,

       

      This might not workout for me. I have both TestComplete and TestExecute installed on my host and remote machines. I sometime have to debug on one of the remote machines due to different os or different project conditions. That will make the dummy folder thing a bit inconvenient.

      I was hoping to just write a small script at the beginning of my tests and use that info to write results etc differently with each kind of run.

       

      Thanks for your help.

       

      Daniel

      • ghuff2's avatar
        ghuff2
        Contributor

        You can try using BuiltIn.ParamStr(0) function to grab the command line executable. That function grabs the command line args like a Java or C-based program, so calling it at index 0 gives the executable string. You'd then have to play around with the string to see if it contains TestComplete.exe or TestExecute.exe. So for example if you launch with TestComplete the BuiltIn.ParamStr(0) will be the string 'C:\Program Files\SmartBear\TestComplete 11\Bin\TestComplete.exe' (or wherever your TestComplete executables is installed.

         

        Here's one way you might do it in python:

         

         

        command_str = BuiltIn.ParamStr(0)
        
        if command_str.find('TestComplete.exe') != -1:
          #Set values for TestComplete
        else:
          #Set values for TestExecute

         

        Or whatever best method you think.