1) Install Maven (Windows)
- Download from maven website and unzip the file.
- Set MAVEN_HOME - <base dire>\apache-maven-3.8.6
- Add to path - <base dire>\apache-maven-3.8.6\bin
2) Test the installation
- Open cmd and type mvn --version
- Should return maven home, version etc.
3) Create a maven project in Eclipse ( You can use maven-quickstart-archetype)
4) Integrate to Eclipse
- Apply Maven Surefire plugin to Eclipse.
- Go to Maven Surefire plugin page >Usage (https://maven.apache.org/surefire/maven-surefire-plugin/usage.html)
- Copy the plugin management snippet and paste in the pom.xml in your eclipse project.
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M7</version>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
Paste this above your dependencies section in the pom.xml.
- now you can run mvn clean, mvn test commands.
5) Integrate TestNG
- We need to add an additional configuration to the plugins section in the pom.xml
- Go to https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html
- <configuration>
- <suiteXmlFiles>
- <suiteXmlFile>testng.xml</suiteXmlFile>
- </suiteXmlFiles>
- </configuration>
- Also you need to add the TestNG dependency to the pom.xml, if its not already added.