Forum Discussion

puyopuy's avatar
puyopuy
Contributor
12 years ago

Run test items in a group

Hi,



I created few groups in TestComplete project, if I selected a group and click "Run Selected Item" menu, TestComplete will execute the test items in the group.  Just wonder how can I use command line to do it? By passing the group name to TestComplete and it will execute the items in that group.



Thanks for your help in advance.

10 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Everybody,


     


    I want to share with you the script that executes the group of test items.


    For this, you need to do the following:


     


    1. Create the RunTestItemGroup.js file with the following contents:


     




    //JScript


    var testItemGroup, project;


     


    var projectSuite = objArgs(0);


    var objArgs = WScript.Arguments;


     


    for (i = 1; i < objArgs.length; i++)


    {


      if (objArgs(i).search(/\/testitemgroup:/i) != -1)


      {


        testItemGroup = objArgs(i).replace(/\/testitemgroup:/i, "");


      }


      if (objArgs(i).search(/\/p:/i) != -1)


      {


        project = objArgs(i).replace(/\/p:/i, "");


      }


      if (objArgs(i).search(/\/project:/i) != -1)


      {


        project = objArgs(i).replace(/\/project:/i, "");


      }


      if (objArgs(i).search(/\/project:/i) != -1)


      {


        project = objArgs(i).replace(/\/project:/i, "");


      }


    }


     


    var tc = new ActiveXObject("TestComplete.TestCompleteApplication.9");


     


    var tci = tc.Integration;


    tc.Visible = true;


    tci.OpenProjectSuite(projectSuite);


    ProjectTestItems = tci.TestSuite(project);


    tci.RunProjectTestItem(project, testItemGroup);


     


    2. To open a TestComplete project and run a group of test items, run the RunTestItemGroup.js script with the appropriate command-line arguments, e.g. the following command line will open the "C:\Users\<UserName>\Documents\TestComplete 9 Projects\TestProject1\TestProject1.pjs" project suite in TestComplete 9 and execute the Group1 test items group in the TestProject1 project:


     


    RunTestItemGroup.js "C:\Users\<UserName>\Documents\TestComplete 9 Projects\TestProject1\TestProject1.pjs" /p:TestProject1 /testitemgroup:Group1


     


    BTW, to learn about the logic of the external RunTestItemGroup.js script, please refer to the "Working With TestComplete via COM - Overview" article and those related.


     

  • Hi,


    Currently, test items' groups cannot be run from the command line. We have suggestions to implement an ability to run specific test items and test item groups in our database. Your request has increased their ratings.


    Thanks

    Ann

  • aniket's avatar
    aniket
    Occasional Contributor
    Is this feature implemented? I couldn't see it in TC9.



    Isn't it logical to run the test item than project item?



    -Aniket
  • aniket's avatar
    aniket
    Occasional Contributor
    Hi Tanya,



    It is couple of extra steps and adding custom application to your test environment.



    If the best and easy way to organize your test is through test items and test items folders.  Then to get continues integration with build it is lot easier if we can call  test items folder. It also give me nice chart in test report :)



    -Aniket
  • Do we know if running test items in a group from the command line is available in

    TestComplete 10
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Jeffrey,

     


    The same way as I listed earlier works in TestComplete 10.


     

    • mjwatkins2's avatar
      mjwatkins2
      Occasional Contributor

      Does anyone know how to do this from a parallel testing job? I need to run 10 scripted tests on a host, which are in a test item group, but I can only pick one test script function per job's task. I cannot pick a test group. Help.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        The only way at the moment is to create a wrapping function that will call test items' 'root' functions and execute this wrapping function from the job.

         

        Slightly more flexible approach is to use the code from above (or from https://support.smartbear.com/viewarticle/54655/), put it into a function and call this function from the job. This approach is more flexible because you should be able to add/remove and enable/disable child items of the called test items group without changing script code.