How to create custom testng.xml and call it from maven?

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

How to create custom testng.xml and call it from maven?

shivanshu sharma
Hi Guys,
Basically i am trying to create an webdriver framework that is with low maintained that i can handle everything from my xlsx file. And i figured that to run tests on multibrowser i need to repeat my code in testng for each browser.i.e.
<test name="Login run on IE" preserve-order="true">
  <parameter name="browser" value="ie"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test> 
  <test name="Login run on firefox" preserve-order="true">
  <parameter name="browser" value="firefox"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test>
  <test name="Login run on Chrome" preserve-order="true">
  <parameter name="browser" value="chrome"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test>

to avoid this i am thinking to pass "All" as a parameter from xlsx and drive this code through java.I haven't tried yet how to create custom testng.xml ...please share detailed link.
Second problem i am facing how to call this class containing main method in Maven?

 

--
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: How to create custom testng.xml and call it from maven?

⇜Krishnan Mahadevan⇝
You don't need to do all that. You merely need to build an implementation for IAlterSuiteListener wherein you are basically creating multiple <test> tags in your suite xml on the fly based on various parameters (You can define a suite level parameter which tells what are all the browsers that need to be executed for as comma separated values, parse it in this listener and then construct <test> tags via your listener)

For a sample refer to this thread wherein I have posted a full fledged implementation which uses the IAlterSuiteListener implementation to achieve somewhat a similar ask.




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/

On Wed, Mar 8, 2017 at 3:26 PM, shivanshu sharma <[hidden email]> wrote:
Hi Guys,
Basically i am trying to create an webdriver framework that is with low maintained that i can handle everything from my xlsx file. And i figured that to run tests on multibrowser i need to repeat my code in testng for each browser.i.e.
<test name="Login run on IE" preserve-order="true">
  <parameter name="browser" value="ie"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test> 
  <test name="Login run on firefox" preserve-order="true">
  <parameter name="browser" value="firefox"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test>
  <test name="Login run on Chrome" preserve-order="true">
  <parameter name="browser" value="chrome"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test>

to avoid this i am thinking to pass "All" as a parameter from xlsx and drive this code through java.I haven't tried yet how to create custom testng.xml ...please share detailed link.
Second problem i am facing how to call this class containing main method in Maven?

 

--
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: How to create custom testng.xml and call it from maven?

shivanshu sharma
Thanks,Will try this.

On Wed, Mar 8, 2017 at 3:59 PM, ⇜Krishnan Mahadevan⇝ <[hidden email]> wrote:
You don't need to do all that. You merely need to build an implementation for IAlterSuiteListener wherein you are basically creating multiple <test> tags in your suite xml on the fly based on various parameters (You can define a suite level parameter which tells what are all the browsers that need to be executed for as comma separated values, parse it in this listener and then construct <test> tags via your listener)

For a sample refer to this thread wherein I have posted a full fledged implementation which uses the IAlterSuiteListener implementation to achieve somewhat a similar ask.




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/

On Wed, Mar 8, 2017 at 3:26 PM, shivanshu sharma <[hidden email]> wrote:
Hi Guys,
Basically i am trying to create an webdriver framework that is with low maintained that i can handle everything from my xlsx file. And i figured that to run tests on multibrowser i need to repeat my code in testng for each browser.i.e.
<test name="Login run on IE" preserve-order="true">
  <parameter name="browser" value="ie"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test> 
  <test name="Login run on firefox" preserve-order="true">
  <parameter name="browser" value="firefox"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test>
  <test name="Login run on Chrome" preserve-order="true">
  <parameter name="browser" value="chrome"></parameter>
  <parameter name="baseURL" value="http://www.example.com/users/login"></parameter>
    <classes>
      <class name="test.LoginPageTest">
           </class>
    </classes>
  </test>

to avoid this i am thinking to pass "All" as a parameter from xlsx and drive this code through java.I haven't tried yet how to create custom testng.xml ...please share detailed link.
Second problem i am facing how to call this class containing main method in Maven?

 

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