Category Archives: Maven

What is REST?

A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.

What is Maven?

Apache Maven. Maven is a build automation tool used primarily for Java projects. Maven addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies.

Installing Maven by setting up the path in Environment Variables in Windows:

  1. Go to the link

download the apache-maven from the above website.

2. Unzip it.

This is the location where you can unzip the folder.

3. Right click on computer —> properties—>advanced system settings—>environment variables—>

User variables:

New–> Make sure that, set the Java path.

variable name: Path

variable path : C:\Program Files\Java\jdk1.8.0_121

Set Maven path:

Click on New—->

variable name: M2_HOME

variable path : C:\Program Files\Apache Software Foundation\apache-maven-3.5.0

Click on New—>

variable name: M2

variable path = %M2_HOME%/bin

Again, click on New–>

variable name:Path

variable value:%M2_HOME%/bin;

Edit the path in System variables:

Add %M2_HOME%/bin after java path .

variable name: path

variable value: C:\Program Files\Java\jdk1.8.0_121\bin;%M2_HOME%/bin;

Open the command prompt type mvn –version:

you will see the maven details.

Maven is successfully installed into the system now, create Jersey project.

Creating a REST(Jersey) + java web application + Maven to project:

  1. open the command prompt. Type mvn archetype: generate for creating Maven Project.

2. Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 958:  

3. Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 

14 (select the archetype as jersey-quickstart-webapp)

4. Enter the version:

Choose a number: 93: 1.19.3

Click enter, again enter.

5. Add groupId, artifactId, version, package details click on enter.

Define value for property ‘groupId’:

Define value for property ‘artifactId’: myApplication

Define value for property ‘version’ 1.0-SNAPSHOT: : 1.19.1

Define value for property ‘package’ :

Confirm properties configuration: 

Put ‘Y’ and then Enter.


The project will be created in the above location.

Version compatibility issue:

Sometimes we got the exception while creating Rest web application with Maven in Eclipse Neon. It cannot be resolved in some cases.

The exception like com.sun.jersey.api.container.ServletContainer:(It’s for 1.x version)


com.glassfish.jersey.api.container.ServletContainer:(It’s for 2.x version)

The Server cannot recognize the ServletContainer which is in web.xml.


We will install the Maven manually by setting the path in an environment variables and create the Rest Maven project in command prompt and then import that project into Eclipse Neon.


Create a dynamic web application and convert into Maven project.

In the Previous Blog we Created a Maven Project.. then the Question comes what is Next??

For Reference of Maven Project Creation link :

In this blog, I am going to discuss about the following :

  • Making Project TestNG Enabled.
  • Project Structure
  • Sample Selenium Test with TestNG annotations
  • Basic Structure of testng.xml
  • Creating profile for testng.xml in pom.xml
  • Executing Selenium test using maven
  • Viewing the Test Reports whether it failed or passed

TestNG is a testing framework for the Java programming language. It is designed to simplify a broad range of testing needs..

Few Advantages :

  • Advance and easy annotations
  • Execution patterns can be set
  • Concurrent execution of test scripts
    • Write the business logic of your test and insert TestNG annotations in your code.
    • Add the information about your test (e.g. the class name, the groups you wish to run, etc…) in a testng.xml file or in build.xml.
    •   testng.xml covers..
      • It can contain one or more tests and is defined by the <suite> tag.
      • A test is represented by <test> and can contain one or more TestNG classes.
      • A TestNG class is a Java class that contains at least one TestNG annotation. It is represented by the <class> tag and can contain one or more test methods.
      • A test method is a Java method annotated by @Test in your source.

      Frequently used annontations

      • @Test :
      • @beforeTest :
      • @AfterTest:
      • @beforeClass

To Start our Maven project with Selenium test and using TestNG.. The below are the steps to follow..

1. TestNG Enable

Make the project TestNG enabled.. we should add TestNG jar dependency details in pom.xml as below.


Create testng.xml ..

   2. Project Structure


    3. Sample Selenium test code along with TestNG

package com.wavelabs.webdriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class AppTest {
 public WebDriver driver;

 public void beforeTest(){
 driver = new FirefoxDriver();
 @Test(description = "facebook open page")
 public void url() {


 @Test(description = "login page", dependsOnMethods = "url")
 public void login() {


The annotations used in the above class are the basic annotations.. there are more like , we can use based on our requirement
@Test : It runs the method.. we have two methods with @Test annotation.. they run based on the parameters passed in the @Test annotation..
The parameter we are using is dependsOnMethods .. it means the method runs only after the url method is passed..

There are other parameters too.. eg : priority=1 , 2 .. etc..

@BeforeTest : This method gets executed before running of the methods who has @Test annotations.. we mostly use the method to initialize the objects of the classes.

   4. Basic Structure of testng.xml

  • test Tag :  the test. there can be multiple test tags in testng.xml
  • classes Tag: The parent tag for child tags (class tag)
  • class Tag : The class which the test tag wants to run.The structure of testng.xml looks like :
    <?xml version="1.0" encoding="UTF-8"?>
    <suite name=" WebDriver Suite">
     <test name="Testing">
     <class name="com.wavelabs.SeleniumTest.AppTest" />


To run the test using Maven, we should create profile for testng.xml in pom.xml..

  5. Creating profile for testng.xml in pom.xml

 <argLine>-Xms2048M -Xmx4096M</argLine>

Note :  we can have multiple testng.xml’s based on our requirement.. but with different names.. instead of testng.xml. we can give any valid name ..

For multiple testng.xml’s we should create multiple <profile> under <profiles> tag (Parent tag )..

6.  Executing Selenium test using maven

Run the command from the path of your project..
To Execute using Maven.. Command to use is :
Syntax :
mvn test -P”ProfileID”
Example :
mvn test -PSampleTest

7. Viewing the Test Reports whether it failed or passed

In the project structure, we see a ‘target folder’ , this folder contains the reports..
The file ‘emailable-report.html‘ gives you the complete report of your test..