Forum Discussion

ajohnson2020's avatar
ajohnson2020
Contributor
11 years ago

Syntax for identifying last test item in a group

Hello all,



I have my test items grouped, and in my OnStopTest handler I want to determine if the current test item I just completed is the last one in the group.  I tried the following syntax (Delphiscript), but get 'The parameter is incorrect'.



if Project.TestItems.Current.Name = Project.TestItems.Current.Parent.TestItem(Project.TestItems.Current.Parent.ItemCount).Name



I verified that Project.TestItems.Current.Parent.ItemCount is returning the correct value (e.g. 6).   I'm sure I'm missing something basic but I'm not seeing it at the moment, what's the proper syntax?  If there's an easier to do what I need I'll take suggestions also, obviously this way relies on the last item in the group always being enabled.



Thanks.





2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The index in TestItem is zero based... so, ItemCount is always going to be one too high.



    Change to



    if Project.TestItems.Current.Name = Project.TestItems.Current.Parent.TestItem(Project.TestItems.Current.Parent.ItemCount-1).Name




    and see if that helps
  • Ah, that's got it.  I think I actually tried that at one point but got confused by other issues at the time and dismissed it.



    Thanks!