Forum Discussion

che_chethan's avatar
che_chethan
Contributor
12 years ago

Issues faced in test complete

Hi,



I have the following requirements that needs to be achieved using test complete:

- How can i run test complete batch tests (we can create a group of test cases in the project suite) group in command line ?



- We have been using Cruisecontrol .net from a long time to manage builds. Is there a way we can integrate test complete automation test cases execution with cruise control .net.



Kindly help !

  • Hi Chethan,


     


    Here's how you can execute the specified group item:


     


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


     


    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 Susmitha,



    Please follow the steps below:



    1. Save the code in the above message by Tania to a .js file (example: Sample.js)

    2. Use the below command in command line to execute group items


    Sample.js "<Path to your project>\<Projectname>.pjs"   /p:<ProjectName> /testitemgroup:<groupname - foldername>



    Hope this helps !



    Regards,

    Chethan

  • Also, you will surely face an error while executing the javasript (As-Is).



    You need to interchange the following statements:


    var projectSuite = objArgs(0);


     


    var objArgs = WScript.Arguments;





    ObjArgs needs to be declared first, else you will find an error as projectSuite will try to fetch value from an undefined variable.

    Updated statements would be:




    var objArgs = WScript.Arguments;


    var projectSuite = objArgs(0);




     



  • Actually, My question is How do I pass the  parameters via commandline. We run our tests on different enviroments based on passing the enviroment name. So here, we are creating a AciveXobject to access the group items. I don't know how to pass the parameters to the Activexobject? I would appreciate if I can get any help on this.



    Thanks,

    Susmitha.
  • Hi Susmitha,



    Please follow the steps below:



    - Create JS file - Sample.js with the code in the thread.

    - Store it locally in the environment you chose to run (Ensure test complete is available - you can make changes to the object being created based on the version of TC that you have)

    Example: 

    TestComplete.TestCompleteApplication.9 for test complete version 9. If you have version 8 then you will have something like:

    TestComplete.TestCompleteApplication.8



    If you want to execute the tests with Test Execute, then


    TestExecute.TestExecuteApplication.9 will be the modification that you have to do to the js file.





    Use the command as mentioned in the earlier reply to execute tests.





    If you face any issues with this, please detail out the steps along with the error that you get which would help us in assisting you to resolve the issue.



    Hope this helps !



    Regards,

    Chethan