Forum Discussion

doublewood's avatar
doublewood
Occasional Contributor
14 years ago

Invoke TestComplete from command line with test parameter

I have created a test and it runs fine from TestComplete.  I would like to run it from command line with parameter pass in thru a batch file.

I can run my proj using the following code from command line


"C:\Program Files (x86)\Automated QA\TestExecute 8\Bin\TestExecute.exe" "C:\Users\mlin\Documents\TestComplete 8 Projects\SerialTestFormation_864\SerialTestFormation_864\SerialTestFormation_864.mds"  /run /exit



I have 3 parameter for the test so far how do I set these parameter from command line.



I did search and poke around for a few hours and have not found the info I need if there's a link for this info I would appreciated.



Thanks for the help in advance

Mark


  • doublewood's avatar
    doublewood
    Occasional Contributor
    Just found out its not possible to pass parameter from command line
  • ya I handle this by reading the parameters from a spreadsheet on each machine's desktop
  • doublewood's avatar
    doublewood
    Occasional Contributor

    I am running Keyword test so I am relying on the TestComplete or TestExecute to pickup the parameter and not writing any script to do that.



    anyway I tried the following code and it did not work. The default parameter value was used when test was run.







    C:\Users\mlin>"C:\Program Files (x86)\Automated QA\TestExecute 8\Bin\TestExecute.exe" "C:\Users\mlin\Documents\TestComplete 8 Projects\SerialTestFormation_864\SerialTestFormation_864\SerialTestFormation_864.mds"  /run "BSUSerialNumber=200000098" "SubnetCount=1" "WRUCount=2" /exit


  • Hi Mark,





    In TestComplete, you need to modify your keyword test so it calls the ProcessCommandLine script routine. You can modify the script in the following way:







    Sub ProcessCommandLine

      index = 0

      For i = 1 To BuiltIn.ParamCount

        index = ProcessCommandLineArgument(BuiltIn.ParamStr(i), index)

      Next

    End Sub





    Function ProcessCommandLineArgument(arg, index)

      Dim items

      items = Split(arg, "=")

      If UBound(items) = 1 Then

        Project.Variables.VariableByName(Project.Variables.GetVariableName(index)) = aqString.Trim(items(1))

        index = index + 1

      End If

      ProcessCommandLineArgument = index

    End Function







    Note that you need to have three (the number of passed parameters) project variables to run the script.





    Then, you will be able to retrieve the passed parameters' values by using project variables.