Forum Discussion

rpfaucher1's avatar
rpfaucher1
Contributor
5 years ago

How to obtain the name of the group when running a group of tests

Howdy, I have a project named "HermansProject" (just as an example lol).... from this project I have created two groups of tests... call them HermansGrp1 and HermansGrp2 (again, just as an example).

 

When I execute a group of tests (e.g. HermansGrp2), I would like each test script to obtain the Group name during it run?

 

How do I get a test script that is running via a group, to get the group name?  

 

I am using VBScripting.

 

Any help appreciated.

 

   Thanks!

  • AlexKaras's avatar
    AlexKaras
    5 years ago

    Hi,

     

    Note: described below will work only if you started test execution using Test Items, exactly as you described. And will not work for tests started as individual routines or keyword tests.

     

    As it is documented in the help topics that I mentioned previously: when TestComplete starts execution of Test Item(s), Project.TestItems.Current object refers to the currently executed test item of the lowest hierarchy. I.e., assuming, that the first test item under Full group is named as A, Project.TestItems.Current will reference test item A, but not Full.

    Now you can iterate up the hierarchy of test items using the Parent property. Parent's value for the Full group will be null (Nothing for VBScript).

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Are you talking about Test Items group?

    If my guess is correct, you may use TestItems and TestItem objects (and their respective .Current, .Parent, etc. properties) to navigate up the hierarchy of the currently executed Test Item.

    The problem is that if you need to navigate not to the top-level group but to stop somewhere in the middle of the hierarchy, then you will have to figure out the criteria because TestComplete does not provide any.

     

    • rpfaucher1's avatar
      rpfaucher1
      Contributor

      Hello and thank you for your reply...

       

      If I am in a Project and I do a "Add New Group" (looks like a File with a green PLUS sign) button to create a suite of tests (if you will) and I create a group, then I drag scripts over into that group... now I can simply click the RUN and that group or suite of tests will run.

       

      For example I have tests that are grouped under "NightlyRunFIP" and I have a set of tests under a group called "Full"... I am looking to see if somehow during the run I can obtain the Group Name of the run.

       

      Snippet below shows what I call two Groups of tests.  I'd like to be able (during a run) to grab the name of the group running so I can write that to a file?

       

       

       

      Thanks again and sorry for any confusion.

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Note: described below will work only if you started test execution using Test Items, exactly as you described. And will not work for tests started as individual routines or keyword tests.

         

        As it is documented in the help topics that I mentioned previously: when TestComplete starts execution of Test Item(s), Project.TestItems.Current object refers to the currently executed test item of the lowest hierarchy. I.e., assuming, that the first test item under Full group is named as A, Project.TestItems.Current will reference test item A, but not Full.

        Now you can iterate up the hierarchy of test items using the Parent property. Parent's value for the Full group will be null (Nothing for VBScript).