Parametrize to Execute TestNG.xml using Maven

Say suppose we have a scenario where we need to execute only a set of TestNG.xml files from the wide range of available xml suite files. It is like we want to run only the specific tests that are in testng.xml files and some times we may again need to kick off other testng.xml files. But for sure we don't want to execute all the suites and wait for them to complete the execution.

Create a Simple Maven Project in Eclipse

In the earlier tutorials, we have seen how to install maven in eclipse. Now we will go ahead and create a simple maven project. Before proceeding, we assume you already installed Maven.

As mentioned earlier MAVEN helps us in creating the project structure, managing and downloading the dependencies. We need to define the required dependencies in pom.xml. We will look more in detail. (By default maven adds few dependencies specific to project structures and that will be based on the archetype that we choose).

First let us create a simple maven project

Install Maven in Eclipse

You can install maven as a plug-in for Eclipse. Using Eclipse Market Place or By using Install new software option.

First let us try installing using an easy way 'Eclipse Market Place'.

After you click on Eclipse market place under help menu, we need to search for maven. It will show you many results with maven. Please select the Maven based on your eclipse version like Maven Integration for Eclipse and m2e connector etc (Kepler/Luna etc).

Creating Project Structure with Maven

As mentioned earlier MAVEN helps us in creating the project structure, managing and downloading the dependencies(MAVEN adds few default dependencies specific to project structures).

How does MAVEN know all this – meaning how is it able to differentiate between project structures, how does it know which project structure needs which dependency?

What is MAVEN?

This tutorial is a brief introduction to MAVEN, we’ll look at what MAVEN is and we’ll also learn how to set up MAVEN.

So what is MAVEN?

Maven is a build / project management tool, based on the concept of a project object model (POM) contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc.