Forum Discussion
What I've done in the past to configure things to run differently on different machines is created an INI file in some directory for the machine in question. I would then make my setting changes in that INI file and let it remain permanently on that machine. At the beginning of a test run, I had code that would read that INI file and then update Project variables to the values in the INI. This would then set up the environment for the test run.
Another option you have is to use a custom commandline parameter. In order to do so, you need to write code to be able to read that command line parameter and utilize it within you tests. I created a script extension not too long ago that contains this code.
https://bitbucket.org/privateteamogre/scriptextensions/downloads/OgreUtilities.tcx
If you have any questions on how to use that utility, let me know via PM.
Question about the custom command line parameter script extension that you referenced: the getTCCommandLineParam. What do I need to do to get that parameter and use it in my TestComplete script? Here's an example of what I'm thinking:
Powershell script:
$testexecute = "C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe"
$p = Start-Process -filepath $testexecute "`"X:\QA\Automated Testing\Vortex\Vortex.pjs`"", /environment qa, /run, /exit
TestComplete Script:
function environment()
{
//Set environment and browser variables based on parameter
ProjectSuite.Variables.Environment = getTCCommandLineParam(environment);
}
That TestComplete script will be the first thing that runs after the Powershell script runs and opens up TestExecute to run all of the tests in that Vortex project suite. Am I on the right track, or would I need to do something different to get that parameter and then use it in the TestComplete script?
- tristaanogre8 years agoEsteemed Contributor
You'll need to reference the object so the code should look something like:
function environment() { //Set environment and browser variables based on parameter ProjectSuite.Variables.Environment = ogreUtils.getTCCommandLineParam(environment); }
That should retrieve the value of the environment command line switch. However, the code as I've written it uses the equal sign in the parameter... so your powershell should look something like the following where the environment is set to equal qa.:
$testexecute = "C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" $p = Start-Process -filepath $testexecute "`"X:\QA\Automated Testing\Vortex\Vortex.pjs`"", /environment=qa, /run, /exit
Let me know if this works for you or if you have additional questions.
- nicklott8 years agoOccasional Contributor
Ok so I've made the changes that you suggested, and here's where I'm at:
When I run the Powershell script, it opens TestExecute, but when it runs my TestComplete script, it errors out on this line:
ProjectSuite.Variables.Environment = ogreUtils.getTCCommandLineParam(environment);
I get an error that says "You cannot run Environment Manager tests with TestExecute".
So instead of using environment, I used this instead:
ProjectSuite.Variables.Environment = ogreUtils.getTCCommandLineParam(env);
I also updated my Powershell script to say /env=qa instead of /environment=qa. When I ran it this time, I didn't get that Environment Manager error, but I did get an error that said that env was not defined. How can I define env so that I can run that TestComplete script?
- tristaanogre8 years agoEsteemed Contributor
Whoops, my bad... didn't notice you weren't calling it as a string. Change your internal code line to
ProjectSuite.Variables.Environment = ogreUtils.getTCCommandLineParam('env');