1

While running selenium suite files from the master file i want to get the suite name of master xml.

I tries using ISuite and ITestContext but it is returning currently running suite name

Master :

<suite name="Master Suite" >
    <listeners>
        <listener class-name="ExtentReport.TestListener" />
    </listeners>
    <suite-files>
        <suite-file path="pri_order_schemes.xml" />
        <suite-file path="pri_sale_schemes.xml" />
    </suite-files>
</suite>

Suite 1:

<suite name="slave 1" preserve-order="false">

    <listeners>
        <listener class-name="ExtentReport.TestListener" />
    </listeners>
    <test name="Bizom Order with QTY based schemes enter QTY in units testing">
        <classes>
           <class name="orders.primaryorders." />
        </classes>
    </test>
</suite>

Suite 2:

<suite name="slave 2" preserve-order="false">
    <listeners>
        <listener class-name="ExtentReport.TestListener" />
    </listeners>
    <test name="Bizom Order with QTY based schemes enter QTY in units testing">
        <classes>
           <class name="orders.primaryorders." />
        </classes>
    </test>
</suite>

I want to get the suite name as "Master Suite" but instead i am getting either "slave 1" or "slave 2"

Sadha Nanda
  • 337
  • 4
  • 15

2 Answers2

1

You can do it by using ITestResult:

iTestResult.getTestContext().getSuite().getName();
Vault23
  • 743
  • 1
  • 5
  • 19
  • No luck :)..ItestResult also returning currently executing suite name not the master suite – Sadha Nanda Sep 27 '19 at 08:08
  • then i will recommend you to put the breakpoint on method where you have instance of iTestResult and check what you can get from it. I have only one suite and lots of tests so i am not able to test it by myself. – Vault23 Sep 27 '19 at 08:13
  • Hi...as i mentioned in my previous comment i am getting the name of slave suite name not the master suite name – Sadha Nanda Sep 27 '19 at 08:53
  • do you run your tests in parallel or not? – Vault23 Sep 27 '19 at 08:55
0

You can get it by below

iTestResult.getTestContext().getSuite().getParentSuite();

Have a look here

user1207289
  • 3,060
  • 6
  • 30
  • 66