Forum Discussion

kso's avatar
kso
Occasional Contributor
15 years ago

Pasing arguments to testexecute command line

Hi,



I would like to be able to pass arguments to unit routine from the testexecute command line.

I have many variables to set depending on the kind of test i want to make:



All the variables can be stored in a file, but how to pass the name/path of the file to a routine from the testexecute command line

in order to update projectsuites variables in the routine



Regards,

   Karim SOUAK.

5 Replies

  • kso's avatar
    kso
    Occasional Contributor
    thank you Jared,,



    here is a snippet of code for those interested in (totaly free).

    I use a flag "/arg" to recognize that it is an argument passed from the command line

    I use this args to create/update projectsuites variables value, but you can do whatever you want.



    //

    //  handle arguments passed on the command line

    //  the command line is in the form:

    // "%ProgramFiles%\Automated QA\TestExecute 7\Bin\TestExecute.exe" <PJS File> /run /project:<project> /unit:<Unit> /routine:handleArguments /arg:S:Solution="FMFI" /arg:S:SgbdType="Oracle" /arg:S:IniFile="fileini.txt" /exit /SilentMode

    //  args can be already defined in the projectsuite or are added if they do not exists.

    //  args are defined by the /arg:<Type>:<Name>=<Value>

    //  Type can be S(string)|I(integer)|D(double)|B(boolean)

    //  the flag /exit must be passed after tha /arg flag.

    function handleArguments()

    {

      var max=BuiltIn.ParamCount();

      var i,tabVar,str;

      var varType = new Array();

      var re = new RegExp("[:=]","g");

     

      // define the type of variable

      varType['S']='String';

      varType['B']='Boolean';

      varType['D']='Double';

      varType['I']='Integer';

     

      // for each param

      for (i=0;i<max;i++) {

         str = BuiltIn.ParamStr(i);

         // if it is an /arg flag

         if(str.indexOf('/arg')!=-1) {

            // Split the flag to get type, name and value of the variable

            tabVar=str.split(re);

            // if the variable is unknown, add it

            if (!ProjectSuite.Variables.VariableExists(tabVar[2]))

                ProjectSuite.Variables.AddVariable(tabVar[2],varType[tabVar[1].toUpperCase()]);

            // set its new value

            eval('ProjectSuite.Variables.'+tabVar[2]+'="'+tabVar[3]+'"');    

        }          

      }

      // this list the default and the local value of the projectsuites variables

      max=ProjectSuite.Variables.VariableCount;

      for (i=0;i<max;i++) {

        // this is the default value

        BuiltIn.ShowMessage('Default :'+ ProjectSuite.Variables.GetVariableName(i)+'='+ProjectSuite.Variables.GetVariableDefaultValue(i));        

        // this is the local value

        BuiltIn.ShowMessage('Local :'+ ProjectSuite.Variables.GetVariableName(i)+'='+eval('ProjectSuite.Variables.'+ProjectSuite.Variables.GetVariableName(i)));        

        }

    }
  • kso's avatar
    kso
    Occasional Contributor
    it seems there is a bug in the way flags are interpreted on the command line .(at least in testexecute 7.52)



    all  flags placed after the /exit files  are not taken into account.



    by example if you place /SilentMode  before /exit  then tc will be excuted in silent mode

    whereas in the contrary if you place /exit before  /SilentMode   then tc will not be executed in silent mode.



     it is the same with custom flags even using ParamStr.



    In the documentation, the flag /Silentmode is placed after  /exit. Ther is something wrong somewhere.



    TestExecute.exe [file_name] [/run 

    [
    (/project:project_name| (/project:project_name /projectitem:item_name| 

    (/project:project_name /unit:unit_name /routine:routine_name)] 

    [/exit] [/SilentMode]



    regards,

      Karim SOUAK.
  • Hi,



    I was unable to reproduce the problem with silent mode - TC uses it regardless of where the /SilentMode parameter is specified. As for obtaining parameters in scripts, use the 'i<=max' condition in your loop.

  • kso's avatar
    kso
    Occasional Contributor
    Hi Jarred,



    you're Right on the two points.

    I don't what i've done....