Home > OS >  BeforeSuite Trouble With Suite of Suites in Testng
BeforeSuite Trouble With Suite of Suites in Testng

Time:09-27

I Have a suite of suites as below. These suites when executed individually, the @BeforeSuite method present in parent class of the included tests runs as expected. But when I combine the suites in one parent suite as below, the @BeforeSuite executes only once.

Is this an expected behavior? Or should the BeforeSuite method execute once for each of the suite files?

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Parent Regression Suite">
    <suite-files>
           <suite-file path="./testng_xmls/LoginTests.xml" ></suite-file>
           <suite-file path="./testng_xmls/Info.xml" ></suite-file>
    </suite-files>
</suite>

CodePudding user response:

Try to add parameter for:

@BeforeSuite(alwaysRun = true)

And for AfterSuite if needed.

CodePudding user response:

I figured out the issue. The problem was elsewhere. The Beforesuite code was getting skipped second suite onward! After the code fix @BeforeSuite is now being executed once for each suite file.

  • Related