Building Multiple Maven Profile in Testng.Xml

Building Multiple Maven Profile in Testng.Xml

Lot of time we have a requirement to run our selenium automation test cases on a different browser, environment or simply as Smoke, Functional, Regression test.

In this blog, we will learn how we can achieve this requirement by creating multiple profiles in our testing.xml file.

To understand this let's take a simple example where we have segregated our automation test script based on the Smoke and Sanity Test and based on client requirement. I wanted to execute either smoke or sanity test. Below is my folder structure

And to execute this automation scripts I have created two separate testing.xml named Sanity.xml and Smoke.xml.

 Now let’s configure maven profile in our POM.xml like below:

As you can view, here I have created two separate maven profile one for executing Smoke automation test another one to execute Sanity automation test.

Now to execute the required profile we need to go to maven command prompt and use

mvn clean test -P profile name
i.e mvn clean test -P Smoke



My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post