Create a Maven project with TestNG
Prerequisites
- Java installed
- Eclipse installed
Step 1: Add TestNG to Eclipse
Open the Eclipse Marketplace by clicking Help and Eclipse Marketplace
Search for
TestNG
Install 'TestNG for Eclipse' by Cédric Buest
Step 2: Create a Maven Project
Click File - New - Other - Maven - Maven Project
Click Next a couple times
On the 'Select an Archetype' page, filter for 'apache.maven.archetype'
Select 'maven-archetype-simple'
click Next
Provide a Group Id and Artifact Id
Click Finish
Step 3: Add TestNG to your project
Right click on your project and select Properties
In the left column, select 'Java Build Path'
Select Libraries
On the right side, select 'Add Libraries'
Select
TestNG
Click Finish
Restart Eclipse
Step 4: Add TestNG to your POM.XML file
Double click on pom.xml
In the 'dependencies' section, add the
TestNG maven dependency
Currently, this is the most used
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
There you have it, Creating a Maven Project with TestNG in 4 easy to follow steps.
--
MichaelComstock - 01 Oct 2020