Forum Discussion

jhopfner's avatar
jhopfner
Occasional Contributor
14 years ago

Running the open project from a script

We currently have the need to use an automatic scheduler and run a TestComplete project from the command line using TestExecute. Before the project's keyword tests are ran, we need to change the values of a couple project variables. This is easy to do from the command line, we simply call a routine that exists in a script in the project. Our problem is, how can we continue running the project as soon as the variables have been changed? Here's the procedure that changes the values of the variables:



procedure OrionNewDev;

begin

  Project.Variables.Server := 'orion';

  Project.Variables.Database := 'newdev';

end;



We're calling the routine as follows:

"C:\Program Files\Automated QA\TestExecute 7\Bin\TestExecute.exe" /run "\\VisEntTest\VisPJSuite\Visions Enterprise Testing Project Suite.pjs" /project:VisClient /unit:Run /routine:OrionNewDev /SilentMode



The support team has instructed us to use
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 12" name="Generator" />
<meta content="Microsoft Word 12" name="Originator" />




KeywordTests.Test_Name.Run(); in the script after changing the variables, however this will only run one keyword test within the procedure. We need the entire project to run the way it's set up (see attachment), to the same effect as right clicking TestExecute's tray icon and selecting Run.



Is this possible to do through scripting?

6 Replies

  • jhopfner's avatar
    jhopfner
    Occasional Contributor
    It's nice to see that after spending thousands of dollars on TestComplete it's hard to get decent support. They're antsy to make a sale but after the purchase the support goes downhill. The live chat agent [Matt] turns you to the email support (ignorantly), the email support takes days, doesn't look into your question but rather fires off the quickest answer they can think of [Tanya], which leaves the forum as the last resort.



    TestComplete is a great product, however AutomatedQA needs to throw a few more dollars into customer service and support.

  • Hi Jordan,





    I suggest that you create a test item that will call the OrionNewDev function and make it the first item in the list of test items. Use the following command line to execute the whole project:

    "C:\Program Files\Automated QA\TestExecute 7\Bin\TestExecute.exe" "\\VisEntTest\VisPJSuite\Visions Enterprise Testing Project Suite.pjs" /run /project:VisClient /SilentMode
  • jhopfner's avatar
    jhopfner
    Occasional Contributor
    Thanks for the reply David.



    Because this test will be ran 3 times a night (each time with different server/database values for the variables), it's not logical for us to put the script as the first test item; if we do this the server/database variables will always contain the same values, unless we modify them manually.



    The way we've currently been doing it is making 3 copies of the project, each contains the different project variable values we need. This is very tedious however; when we want to make a change to the script we have to copy the project again 3 times and modify each one to contain the correct values for each variable. This is why it would be nice to be able to modify these variables first from the script and continue running the rest of the keyword tests.



    Better yet, it would be great if a user could modify these variables directly from the command line and run the test, something like:



    10pm - "C:\Program
    Files\Automated QA\TestExecute 7\Bin\TestExecute.exe" /run
    "\\VisEntTest\VisPJSuite\Visions Enterprise Testing Project Suite.pjs"
    /project:VisClient /var:Server=orion /var:Database=newdev /SilentMode



    11pm - "C:\Program
    Files\Automated QA\TestExecute 7\Bin\TestExecute.exe" /run
    "\\VisEntTest\VisPJSuite\Visions Enterprise Testing Project Suite.pjs"
    /project:VisClient /var:Server=aries /var:Database=testing /SilentMode



    ... and so on.



    I know this isn't currently possible, however it would be a great feature addition. For now, is there any way to modify the variables through a script and continue running the rest of the keyword tests?
  • Hi,


    You can create your own command line parameters and handle them via BuiltIn.ParamStr


    eg with database and server name in your case, you can use any value after "/server:" and "/database:"


    "C:\Program Files\Automated QA\TestExecute 7\Bin\TestExecute.exe" "\\VisEntTest\VisPJSuite\Visions Enterprise Testing Project Suite.pjs" /run /project:VisClient /server:orion /database:newdev /SilentMode /e


    And then handle your new parameters from script like this and pass them to project variables (JScript):


    for (var i=0; i<BuiltIn.ParamCount(); i++)


    {


    if (BuiltIn.ParamStr(i).substr(0,7)=="/server")


    Project.Variables.Server=BuiltIn.ParamStr(i).slice(8);







    if (BuiltIn.ParamStr(i).substr(0,9)=="/database")


    Project.Variables.Database=BuiltIn.ParamStr(i).slice(10);



    }



  • jhopfner's avatar
    jhopfner
    Occasional Contributor
    That is exactly what we needed Pavel, thank you very much for the detailed code! It works flawlessly, much appreciated!



    David, thanks for the link to the help topic.