When running this test (ChildTest), I would expect that both test methods (childTestMethod and parentTestMethod) belong to group 'myGroup'. Apparently this is not the actual behavior (tested with version 6.4).

I looked into the TestNG source code, and it appears that this behavior originates from the method org.testng.internal.BaseTestMethod#initGroups(Class<?>). To be exact, I think the following statement is the cause of this rather odd behavior:

I see the problem, and your suggestion doesn't quite work, unfortunately. It's a bit tricky to solve because annotations are resolved in the init phase, which means that when the parent's @test annotation is parsed, it obviously knows nothing about the fact that the child annotation will add more groups to it...

Cedric, thank you for your prompt feedback on this issue. You say "it is a bit tricky to solve", does that mean that you do not think that this issue will have a chance of being resolved in the near future? Can you think about any possible workarounds?

What I meant was: when the group resolution is performed, no test class has been instantiated yet, so when I look at parentTestMethod(), I don't have an instance of ChildTest that would allow me to put that method in this group.

Group resolution is purely static, while the example above can only be resolved dynamically.

I have seen this behavior as well. When I run my tests without a groups filter, everything passes, but when running with groups, things fail. In some cases it is due to my test class inheriting from some other test class, but in other cases I have POJO test classes and it seems like my @BeforeMethod and @AfterMethod methods are not invoked properly.

More than a year later and this still does not work.@cbeust IMHO this does not make any sense: since the parent class is abstract, its group resolution should be based in a concrete instance of a test class.