Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before/AfterSuite methods may not run, when classes from suite use inheritance, and one of them has enabled=false set. #420

Closed
kubicz10 opened this issue Aug 9, 2013 · 1 comment

Comments

@kubicz10
Copy link

kubicz10 commented Aug 9, 2013

Hi,

I think this is a bug, and pretty nasty one too, because it may or may not manifest depending on the order of tests.

TestNG version 6.8.5.

I have three test classes: BaseTestCase (abstract, implementing BeforeSuite method with alwaysRun=true), FirstSample (which derives from BaseTestCase), and SecondSample (it derives from BaseTestCase too).

This classes are included in suite.xml.

If FirstSample class is annotated with Test(enabled=false), BeforeSuite will probably NOT run.
If SecondSample class is annotated with Test(enabled=false), BeforeSuite will probably run.

Sometimes the order changes, but the rule is the same: two (or more) test classes, deriving from one base class, one of which is annotated with enabled=false.

Here's the code to reproduce:

BaseTestCase.java:

public abstract class BaseTestCase{

    protected final static Logger logger = LoggerFactory.getLogger(BaseTestCase.class);

    @BeforeSuite(alwaysRun = true)
    public static void initEnvironment() {
        logger.info("executed initEnvironment (@BeforeSuite)");
    }
}

FirstSample.java:

@Test(enabled = false)
public class FirstSample extends BaseTestCase {

    @Test
    public void verifySomethingFirstSample() {
        Assert.isTrue(true);
    }
}

SecondSample.java:

public class SecondSample extends BaseTestCase {

    @Test
    public void verifySomethingSecondSample() {
        Assert.isTrue(false);
    }
}

sample-tests.xml:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Sample Tests" verbose="2" parallel="classes" thread-count="6">
    <test name="Sample test(s)">
        <packages><package name="com.sampletests"/></packages>
    </test>
</suite>
@Nugs
Copy link

Nugs commented Jun 25, 2014

We are also experiencing this issue within our project using 6.8.8.

juherr pushed a commit to juherr/testng that referenced this issue May 9, 2015
@juherr juherr closed this as completed May 9, 2015
@juherr juherr reopened this May 9, 2015
@juherr juherr closed this as completed in 328620f May 22, 2015
cbeust added a commit that referenced this issue May 22, 2015
Fix #420 Before/AfterSuite methods may not run, when classes from suite use inheritance, and one of them has enabled=false set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants