Question

Due to the fact that my setups keeps growing I'd like to use some more features of TestNG. So today I tried to exclude a groud in my testng.xml file.

When I declare a whole Class to be part of a group, this doesn't prevent the constructor to do it's work (initiating a WebDriver instance).

@Test(groups = "default")
public class ABCDefaultTest extends AbstractABCTest {

    public ABCDefaultTest() {
        super();
    }


}

Please note: AbstractABCTest is part of "abc" group

I thought of quitting the WebDriver in the AfterClass method and added (alwaysRun = true) but that didn't work.

Seems that the constructor isn't part of the group (which is good if you have different groups in one class) but the @AfterClass (alwaysRun = true) annotated method is...

But if there's only the group specified for the class and no partial groups it makes no sense to initiate the class right?

Can you tell me what I'm doing wrong or if this is a bug?

Était-ce utile?

La solution

Your interpretation is correct, groups only apply to TestNG annotated methods. You should avoid doing work in the constructor that you don't want to happen if a group is excluded.

How about doing this work in a @Before* method that belongs to that group? Then you just need to decide which configuration method is appropriate for you: @BeforeSuite, @BeforeTest, @BeforeGroup or @BeforeClass.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top