How to get the name of the test in @beforeTest method

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to get the name of the test in @beforeTest method

Nainappa Illi
Hi,

My sample Testng.xml is:

<suite name="SampleSuite">
     <test name="SampleTest">
        <classes>
            <class name="class1"/>
            <class name="class2"/>
        </classes>
    </test>
</suite>

In my @beforeTest method, I need either the <test> name or <class> name. How can I get that?

Thanks in Advance.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get the name of the test in @beforeTest method

Nainappa Illi
Got the answer. We should be using ITestContext as the parameter for beforetest method. Something as below.

 @BeforeTest(alwaysRun = true)
  public void setup(ITestContext context) throws Exception {
    String className = getClass().getSimpleName();
  }

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...