How to run multiple test suites using maven

9,456 views
Skip to first unread message

Rivlin Pereira

unread,
Jun 19, 2012, 3:40:08 PM6/19/12
to seleniu...@googlegroups.com
All,

First of all apologies for posting this question in selenium group. I am using maven for doing builds and using the suirefire plugin to run webdriver tests. I have multiple suite files and i am trying to figure out how to run xml file of my choice from them.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12</version>
                <configuration>
                    <!-- Configuring the test suites to execute -->
                    <suiteXmlFiles>
                        <suiteXmlFile>test-suites/audiosuiteFirefox.xml</suiteXmlFile>
                        <suiteXmlFile>test-suites/addcontentsuiteFirefox.xml</suiteXmlFile>
                        <suiteXmlFile>test-suites/audiosuiteChrome.xml</suiteXmlFile>
                        <suiteXmlFile>test-suites/corepublishersuite.xml</suiteXmlFile>
                        <suiteXmlFile>test-suites/tablequeuesuiteFirefox.xml</suiteXmlFile>
                    </suiteXmlFiles>

                </configuration>
            </plugin>

I am using mvn clean test -Dtest='my suite file' but i am not able to run my suite file. Any ideas how to get around this?

Thanks,

Frank Escobar

unread,
Jun 19, 2012, 3:49:34 PM6/19/12
to seleniu...@googlegroups.com
I think that just you can run tests suites in parallel from one file xml. You should specify in a file all you testsuites.  For example:

MY TESTNG.XML

<?xml version="1.0" encoding="UTF-8"?>
<suite name="REGRESSION TESTS" parallel="tests" verbose="1" thread-count="3">
<parameter name="serverHost" value="localhost" />
<parameter name="serverPort" value="4444" />
<parameter name="environmentDRCC" value="http://localhost:9095/system-gui/" />

<test name="Tests in CHROME" preserve-order="true">
  <parameter name="browser" value="chrome" />
     <classes>
        <class name="com.system.tests.SmokeTest"/>
    </classes>
</test>

<test name="Tests in FIREFOX" preserve-order="true">
  <parameter name="browser" value="firefox" />
    <classes>
      <class name="com.system.tests.SmokeTest"/>
    </classes>
</test>

</suite>

MY POM.XML

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/com/system/configurations/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/1kDy2WZk-m8J.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.




--

Frank Escobar | QA Analyst
GlobalLogic Inc. | Innovation by Design
ARGENTINA | CHILE | CHINA | GERMANY | INDIA | ISRAEL | UKRAINE | UK | USA
Av. Corrientes 485 piso 6 | Buenos Aires, 1043
Office: +54.11.5533.8300 x 1018 | Mobile: +54.9.11.4394.3121

www.globallogic.com
www.globallogic.com/email_disclaimer.txt

Rivlin Pereira

unread,
Jun 19, 2012, 4:08:26 PM6/19/12
to seleniu...@googlegroups.com
Hi Frank,

Thanks for your quick reply. I will try that. It is interesting with maven though how you can do things. I was using ant previously and there was a way to run a xml file of your choice from command line. But this option that you have suggested sounds good. 

Thanks,

Krishnan Mahadevan

unread,
Jun 19, 2012, 10:18:28 PM6/19/12
to seleniu...@googlegroups.com
Rivlin,
The option suggested by Frank will ensure all your tests are run. 

Here is what you can do in your pom file if you want to be able to pick and choose what suite to run at run time. 

Define a property in your pom file

<properties>
<suiteFile>src/test/resources/myxml.xml</suiteFile>
</properties>

now refer this property in your surefire plug-in. 

<suiteXmlFiles>
<suiteXmlFile>${suiteFile}</suiteXmlFile>
</suiteXmlFiles>

Once this is done you can switch to any suite file of your choice by passing the file name from command. 

mvn clean test -DsuiteFile=src/test/resources/another.xml
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.


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

Rivlin Pereira

unread,
Jun 19, 2012, 11:36:31 PM6/19/12
to seleniu...@googlegroups.com
Hi Krishnan,

Thank you for your input. I definitely have everything I need now :)

Thanks,

Krishnan Mahadevan

unread,
Jun 19, 2012, 11:39:54 PM6/19/12
to seleniu...@googlegroups.com
You are welcome :)
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Nathan Beach

unread,
Aug 15, 2013, 2:51:59 PM8/15/13
to seleniu...@googlegroups.com
Krishnan -- you are a genius.  That suiteFile property idea worked perfectly for me.  

I'm surprised more people on earth don't seem to want to be able to run a specific suite xml file (I've searched all over for a way before I found this thread). 

If this were on stackoverflow, I'd upvote you.  Thanks!

NBB

Krishnan Mahadevan

unread,
Aug 18, 2013, 12:48:22 PM8/18/13
to seleniu...@googlegroups.com
Am glad it worked. :)
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/12b4d8b2-1365-4c04-b2c2-466852dfaff7%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

urbu...@gmail.com

unread,
Aug 5, 2015, 2:15:17 PM8/5/15
to Selenium Users
H Krishnan,

I am new to selenium a,TestNG and maven, but the same requirement i need to implement in my project. please can you share samples how you achieved this.

1. How to create testsuite xml in selenium
2. how we can run a required suite from different test suites
3.is it required to configure all test suites in testng?
4.how to configure that testNG xml file in POM XML?
5.how i can run a specific test suite from maven.

please, dont mind, am very new to this tool.

Krishnan Mahadevan

unread,
Aug 5, 2015, 11:41:06 PM8/5/15
to Selenium Users
First things first.
Your query doesn't have anything to do with WebDriver/Selenium. I would recommend that you please post your query [ 1 post per query is what I would recommend ] in the testng-users google forum.

My answers to your questions :

1. How to create testsuite xml in selenium

2. how we can run a required suite from different test suites
>>>>>>>>>>>>I am not sure what you are asking for here.

3.is it required to configure all test suites in testng?
>>>>>>>>>>>>Not sure what you are asking for here.

4.how to configure that testNG xml file in POM XML?

5.how i can run a specific test suite from maven.
>>>>>>>>>>>>The answer to this question already is answered by me in this thread in an earlier response. Please go through this thread once again.



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/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Srikanth K

unread,
May 13, 2016, 12:09:50 PM5/13/16
to Selenium Users
Hello Krishnan,

i have tried running selected suite as per your instructions but maven runs all the suites mentioned under surefire plugin. Need your help to fix this issue.

Thanks in advance

Srikanth K

unread,
May 13, 2016, 12:09:50 PM5/13/16
to Selenium Users
Hello Krishnan,

I have set up my project as per you instructions but all the suites names under surefire plugin are running instead of the selected suite in the command. Need your help to fix this issue as i have run out of all the options trying to fix it.

Thanks in advance

On Thursday, 6 August 2015 09:11:06 UTC+5:30, Krishnan wrote:

Srikanth K

unread,
May 13, 2016, 12:09:51 PM5/13/16
to Selenium Users
Hello Krishnan,
i have added the testng xml files under src/test/resources, then, in the pom, i have added the property -
 <properties>
          <suiteFile>src/test/resources/abc.xml</suiteFile>
          <suiteFile>src/test/resources/def.xml</suiteFile>
  </properties>
and, under surefire plugin,
<suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/abc.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/def.xml</suiteXmlFile>
 </suiteXmlFiles>.
i run the command "mvn clean test -DsuiteXmlFile=src/test/resources/abc.xml"
Still  Don't have a clue why it is running all the suites? Please help me with your inputs as to what might be wrong?

Thanks in advance ... 
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.

⇜Krishnan Mahadevan⇝

unread,
May 13, 2016, 12:14:04 PM5/13/16
to Selenium Users
Srikanth,
You might want to take a look at this blog post of mine and see if that helps : https://rationaleemotions.wordpress.com/2016/03/29/parallel-execution-of-multiple-testng-suites/

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/
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.


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

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

Suresh Sana

unread,
Nov 8, 2016, 4:30:20 AM11/8/16
to Selenium Users
Hi Krishnan,

Seeking your help, i am new to maven.
Below solution is working for me, but i want to pass only the 'Suite name' (not with complete path) from command line.
can you help me achieving this.
Thanks in advance!!

Thanks,
Suresh
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.

⇜Krishnan Mahadevan⇝

unread,
Nov 8, 2016, 5:24:28 AM11/8/16
to Selenium Users
You should be able to do it like below :

Define a property in your pom file

<properties>
<suiteFolder>src/test/resources</suiteFolder>
<suiteFile>myxml.xml</suiteFile>
</properties>

now refer this property in your surefire plug-in. 

<suiteXmlFiles>
<suiteXmlFile>${suiteFolder}/${suiteFile}</suiteXmlFile>
</suiteXmlFiles>

With this, you now have the ability to change both the folder and the file.

Use -DsuiteFolder if you want to point to a different folder and 
Use -DsuiteFile -f you want to point to a different file.

If you don't pass either of the above two args, the default value will be taken [ default value is what you defined in the <properties> section ]


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/
To post to this group, send email to seleniu...@googlegroups.com.

To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.


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

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.

To post to this group, send email to selenium-users@googlegroups.com.

bert Zhang

unread,
Apr 6, 2017, 5:36:00 PM4/6/17
to Selenium Users
Hi Krishnan

first of all, thank you for your method provided here, i just try to use your way $${suiteFolder}/${suiteFile} to set in the pom.xml, but i found i am not able to run multiple testng.xml, i run mvn command like: mvn clean install -DsuiteFile=testng1.xml, testng2.xml and it is not running, it seems i can only assign one testng.xml file if i set two property ${suiteFolder}/${suiteFile}
To post to this group, send email to selenium-users@googlegroups.com.

To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.


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

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
Message has been deleted
Message has been deleted

Boopathi krishnamoorthy

unread,
Apr 26, 2018, 12:48:13 AM4/26/18
to Selenium Users
Hi krishna,
   I have created testng.xml and created suite with two classes as below
<classes>
<class name="com.dtcc.ete.ui.SettlWebDashboardTest" />
<class name="com.dtcc.ete.ui.WindownLimitsProfileTest" />
</classes>

but i need to run only specific tests like Regression or Smoke through mvn command line and i tried the below command but it was not working for me but the same command is working fine to one of my team mate.
 i have created @ test as
@Test(groups ={"sanity","regression"},enabled = true,description="Verify SettlWebDashboard", dataProvider = "SWebAutomation")

Command i have used:
mvn test -Dgroups=regression

please suggest .
Thanks
Boopathi

Adiesha Liyanage

unread,
Sep 6, 2018, 2:10:46 PM9/6/18
to Selenium Users
Thanks I was looking for a solution for this
Reply all
Reply to author
Forward
0 new messages