Need clarity on IAlterSuiteListener.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Need clarity on IAlterSuiteListener.

Ashish Yadav
Hi All,

Could you please suggest me how to implement and configure IAlterSuiteListener in TestNG framework.
I want to use this listener to rerun my whole TestNG.class on different different browsers.
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
|

Re: Need clarity on IAlterSuiteListener.

Todd Bradley-2
Why do you think IAlterSuiteListener is the best approach to solve that problem? It seems like data providers or factories would be a better approach.


Todd.

On Wed, Feb 28, 2018 at 1:53 AM, Ashish Yadav <[hidden email]> wrote:
Hi All,

Could you please suggest me how to implement and configure IAlterSuiteListener in TestNG framework.
I want to use this listener to rerun my whole TestNG.class on different different browsers.
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.

--
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
|

Re: Need clarity on IAlterSuiteListener.

Krishnan Mahadevan

Ashish,

IAlterSuiteListener is executed before the tests are executed. So there is no notion of “re-running” here because execution has not even started.

 

But if you are trying out the below scenario, then IAlterSuiteListener is the perfect way of doing it.

 

  • You have a bunch of tests that are part of a <test> tag.
  • You specify the browser flavor via a parameter such as: <parameter name=”browser” value=”firefox”/>

 

Is that what you are trying to solve?

 

If yes, then you can do something like below: (Please feel free to modify this to suite your specific needs. This sample is just for illustrative purposes ONLY)

 

public class SuiteChanger implements IAlterSuiteListener {

 

    @Override

    public void alter(List<XmlSuite> list) {

        XmlSuite suite = list.get(0);

        //We are assuming that our suite will have ONLY ONE <test>

        XmlTest xmlTest = suite.getTests().get(0);

        XmlTest newTest = (XmlTest) xmlTest.clone();

        newTest.getLocalParameters().put("browser", "internetexplorer");

        suite.addTest(newTest);

        newTest = (XmlTest) xmlTest.clone();

        newTest.getLocalParameters().put("browser", "chrome");

        suite.addTest(newTest);

    }

}

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

Reply-To: <[hidden email]>
Date: Wednesday, February 28, 2018 at 8:49 PM
To: <[hidden email]>
Subject: Re: [testng-users] Need clarity on IAlterSuiteListener.

 

Why do you think IAlterSuiteListener is the best approach to solve that problem? It seems like data providers or factories would be a better approach.





Todd.

 

On Wed, Feb 28, 2018 at 1:53 AM, Ashish Yadav <[hidden email]> wrote:

Hi All,

 

Could you please suggest me how to implement and configure IAlterSuiteListener in TestNG framework.

I want to use this listener to rerun my whole TestNG.class on different different browsers.

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.

 

--
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.

--
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.