cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Occasional Contributor

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

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

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).

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

4 REPLIES 4
Highlighted
Community Hero

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

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
Occasional Contributor

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

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?

 

rpfaucher1_1-1600981533060.png

 

 

Thanks again and sorry for any confusion.

 

Highlighted
Community Hero

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

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).

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Occasional Contributor

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

Thank you and will look into this, appreciate the assist.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors