How to Create Sample Maven Project by Adding TestNG

Here are the steps to create the sample Maven project and how to add the TestNG dependencies.

Step 1

  1. Open your Eclipse environment and navigate to the "File" menu.
  2. Select "New" and then choose "Project."

By following these steps, you initiate the process of creating a new Maven project in your environment.

Maven Project

Step 2

After initiating the project creation process, as mentioned before, proceed to the next step.

Open the Maven screen by clicking "Next." This step allows you to configure Maven-specific settings for your project.

Maven new project

Step 3

As part of the Maven project setup, you'll encounter a screen displaying various options, including Group IDs, Artifact IDs, and Versions.

Choose the appropriate plugin by selecting the desired Group ID, Artifact ID, and Version. Once selected, proceed by clicking "Next."

In these steps, you specify the essential project coordinates, ensuring the proper configuration for your Maven project

New Maven

Step 4

In the subsequent dialog box, provide the necessary project details:

Ex: Enter "Newmavan.project" as the Group ID.

Specify "firstproject" as the Artifact ID.

The version will be automatically generated and will be adjustable later if needed. Confirm your entries and proceed by clicking "Finish."

In these steps, you define specific details for your Maven project.

Maven advanced

Step 5

Upon completion, your newly created project will be visible as below.

Eclipse IDE

Step 6

Within the project structure, locate the file named "AppTest.java".

Open "AppTest.java" to reveal the JUnit test cases, which will be displayed directly on your Eclipse screen upon access.

App test

Step 7

Add dependencies to POM.xml.

  1. Open the POM.xml file in your Maven project.
  2. Add the Selenium and testNG dependencies to the POM.xml file using the following entries:

TestNG dependency: https://mvnrepository.com/artifact/org.testng/testng

Selenium dependency: https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java

Eclipse IDE Code

Step 8

Execute the program by using TestNG.

TestNg


Similar Articles