Tuesday, November 15, 2022

Beginners Spot - Setup Maven in Test Automation environment

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.

  1. <build>
  2. <pluginManagement>
  3. <plugins>
  4. <plugin>
  5. <groupId>org.apache.maven.plugins</groupId>
  6. <artifactId>maven-surefire-plugin</artifactId>
  7. <version>3.0.0-M7</version>
  8. </plugin>
  9. </plugins>
  10. </pluginManagement>
  11. </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

  1. <configuration>
  2. <suiteXmlFiles>
  3. <suiteXmlFile>testng.xml</suiteXmlFile>
  4. </suiteXmlFiles>
  5. </configuration>

- Also you need to add the TestNG dependency to the pom.xml, if its not already added.


No comments:

Post a Comment

Featured

Selenium - Page Object Model and Action Methods

  How we change this code to PageObjectModel and action classes. 1 2 3 driver . findElement ( By . id ( "userEmail" )). sendKeys (...

Popular Posts