Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
6 years ago
Solved

Is it possible to run Test Item with Parameters from command line (TestExecute)

My Test-Item has 3 parameters which I can set in the Test Item Overview menue in TestComplete, but can I alter them from the command line?   What I want to do in particular is, I start TestExecute ...
  • cunderw's avatar
    6 years ago

    Not specifically the way you are wanting, but you can write something to figure out what command line parameters Test Execute is launched with: 

     

    https://support.smartbear.com/testcomplete/docs/working-with/automating/command-line-and-exit-codes/command-line.html

     

    function CommandLineArgs()
    {
      var i;
      var nArgs = BuiltIn.ParamCount();
      Log.Message("Total number of command-line arguments: " + nArgs);
      Log.Message("The fully-qualified name of the TestComplete executable: " + BuiltIn.ParamStr(0));
    
      for (i = 1; i <= nArgs ; i++)
        Log.Message("Arg " + i + ": " + BuiltIn.ParamStr(i));
    }

    I don't really like this method myself, so what we do is create a text file with a json string in it to configure environments.

     

    In jenkins you can echo the string to your workspace root with a windows batch command:

     

    echo { "param1" : "%<jenkinsParam1%>, "param2" : "%<jenkinsParam2%> "} > envConfig.json

    Then use an on start test event handler to read that info in and parse it to and object. 

     

    JSON.parse(aqFile.ReadWholeTextFile(filePath, aqFile.ctUTF8));

     

    Set that to a project variable and then you can call properties off of the object like you would anything else.

     

    Either way works, I find there are is a lot more room for configuration with the config file approach though and is much easier to maintain / extend.