I am trying to measure the number of testitems (enabled/disabled) in my project for statistical purposes, to compare different testruns.
While iterating through Project.TestItems.TestItem, i did not find a way to distinguish tests from (sometimes empty) groups. I tried to use the ElementToBeRun Property, but had no success. Testitems and folders seem to be handled identical.
thank you for your answer. This solution was my first try too, but it does not solve my problem. Maybe I should have been more precise.
Here is an example testitem structure and the result of the script:
1. Test (enabled)
2. Group (enabled)
2.2. Test (enabled)
2.3. Test (enabled)
2.4. Subgroup (enabled, but empty)
3. Group (enabled, but empty)
Result: Items: 5 Groups: 3 Enabled: 5
The empty groups are getting counted as tests too. Those Groups are placeholders right now, and are going to be filled during expansion.
I reorganized your script a little bit and found the following solution working for me. Right now neither disabled groups nor their childs are getting counted, because those tests are not running and not of interest (for me). Maybe in the future those will be added with additional counters.