Actually, that does not work. Specifying groups on a configuration
method only says that the configuration method is in those groups, not
that it will run before those groups and none else. What I want to do
is like @BeforeMethod.forGroups--run the configuration method before
every method in a matching group. So, for a test class with
@BeforeMethod
public void beforeMethodForAll() {
System.out.println("beforeMethodForAll");
}
@BeforeMethod(forGroups = "GroupA")
public void beforeMethodForGroupA() {
System.out.println("beforeMethodForGroupA");
}
@Test
public void testWithoutGroups() {
System.out.println("testWithoutGroups");
}
@Test(groups = "GroupA")
public void testInGroupA() {
System.out.println("testInGroupA");
}
@Test(groups = "GroupB")
public void testInGroupB() {
System.out.println("testInGroupB");
}
running the entire test class in a single suite, and if the order of
execution is testWithoutGroups, then testInGroupA, then testInGroupB,
I would see
beforeMethodForAll
testWithoutGroups
---
beforeMethodForAll
beforeMethodForGroupA
testInGroupA
--
beforeMethodForAll
testInGroupB
Am I overlooking an existing way of achieving this?
On Apr 26, 10:17 am, Choey <
choey...@gmail.com> wrote:
> Hmm, that works. That requires figuring out the set of all groups,
> minus the group for which I'm trying to create theconfiguration method, but that's not a big issue for me.
>
> Thanks!
>
> On Apr 26, 2010, at 9:59 AM, Yves Dessertine ☼
>
>
>
>
>
> <
yvesd.pub...@gmail.com> wrote:
> >> But if that commonmethodhappens to be an ungroupedconfiguration
> >>method, it gets run twice.
>
> > Not if you have:
>
> > // Specify all other groups
> > @BeforeMethod(groups={"Group2", "Group3", "BlahBlahGroup"}
> > protected void setUp()
> > {
> > doCommonSetup();
> > System.out.println("MyTestBase.setUp()");
>
> > }
>
> > @BeforeMethod(groups = "Group1")
> > protected void setUpBeforeGroup1()
> > {
> > doCommonSetup();
> > System.out.println("MyTestBase.setUpBeforeGroup1()");
>
> > }
>
> > The drawback is that you have to specify each group, but I don't see a
> > bettermethodyet.
>
> > Yves
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "testng-users" group.
> > To post to this group, send email to
testng...@googlegroups.com.
> > To unsubscribe from this group, send email to
testng-users...@googlegroups.com
> > .
> > For more options, visit this group athttp://
groups.google.com/group/testng-users?hl=en