cancel
Showing results for 
Search instead for 
Did you mean: 

TestExectute run configuring project variable

SOLVED
Contributor

TestExectute run configuring project variable

Hi to all,

In my project I have defined a variable(in section temporary variable), I use it to change enviroment, from production to quality.

I want to run with testexecute configuring my var.

My bat is:

TestExecute.exe "V:\Users\Administrator\Documents\TestComplete 14 Projects\DLConsole\DLConsole.pjs" /r /pSmiley Very HappyLConsoleGUI /t:"Dragon 5|MyAcount" /ErrorLog:"c:\log.txt" /Enviroment="dev" /e

 

Where Enviroment is my variable.

 

I set it but this variable do not change enviroment.

Suggestions

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: TestExectute run configuring project variable

Correct... because TestExecute does not recognize the commandline switch "Environment".... there are commandline switches it does recognize but anything beyond those you need to write you're own code for.

 

Two ways to do what you want, and I've done both with high success:

 

1) Utilize Storages.INI object and methods to read values from an INI file into the desired variable or variables.  This allows you to alter the file as needed on different machines, etc., to create different unique run configurations.

 

2) Write code to read the commandline of TestExecute and parse out commandline switches.   This is a little more complicated so here's the code I use for it, in JScript.

 

function getCommandLineParameter(parameterString) {
    
    var string;
    var parameterListLength;
    var foundParameter;
    try {
        if (Sys.WaitProcess('TestExecute').Exists) {
            string = Sys.Process('TestExecute').CommandLine;
        }
        else {
            string = Sys.Process('TestComplete').CommandLine;
        }
        //Setting the list separator to grab a parameter     
        aqString.ListSeparator = '/';
        parameterListLength = aqString.GetListLength(string);
        for (var i = 1; i < parameterListLength; i ++) {
            if (aqString.Find(aqString.ToUpper(aqString.GetListItem(string, i)), aqString.ToUpper(parameterString)) != -1) {
                foundParameter = aqString.GetListItem(string, i);
                break;
            }    
        }
        if (foundParameter == undefined) {
            aqString.ListSeparator = '|';
            return -1;
        }
        //Resetting list separator back to default
        aqString.ListSeparator = '|';
        return aqString.SubString(foundParameter, aqString.Find(foundParameter, '=') + 1, foundParameter.length);
    }
    catch (exception){
        Log.Error('An error occurred getting the commandline parameter: ' + exception.message);
        return -1;
    } 
}

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

1 REPLY 1
Highlighted
Community Hero

Re: TestExectute run configuring project variable

Correct... because TestExecute does not recognize the commandline switch "Environment".... there are commandline switches it does recognize but anything beyond those you need to write you're own code for.

 

Two ways to do what you want, and I've done both with high success:

 

1) Utilize Storages.INI object and methods to read values from an INI file into the desired variable or variables.  This allows you to alter the file as needed on different machines, etc., to create different unique run configurations.

 

2) Write code to read the commandline of TestExecute and parse out commandline switches.   This is a little more complicated so here's the code I use for it, in JScript.

 

function getCommandLineParameter(parameterString) {
    
    var string;
    var parameterListLength;
    var foundParameter;
    try {
        if (Sys.WaitProcess('TestExecute').Exists) {
            string = Sys.Process('TestExecute').CommandLine;
        }
        else {
            string = Sys.Process('TestComplete').CommandLine;
        }
        //Setting the list separator to grab a parameter     
        aqString.ListSeparator = '/';
        parameterListLength = aqString.GetListLength(string);
        for (var i = 1; i < parameterListLength; i ++) {
            if (aqString.Find(aqString.ToUpper(aqString.GetListItem(string, i)), aqString.ToUpper(parameterString)) != -1) {
                foundParameter = aqString.GetListItem(string, i);
                break;
            }    
        }
        if (foundParameter == undefined) {
            aqString.ListSeparator = '|';
            return -1;
        }
        //Resetting list separator back to default
        aqString.ListSeparator = '|';
        return aqString.SubString(foundParameter, aqString.Find(foundParameter, '=') + 1, foundParameter.length);
    }
    catch (exception){
        Log.Error('An error occurred getting the commandline parameter: ' + exception.message);
        return -1;
    } 
}

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post