Search⌘ K
AI Features

How to Execute Automated Tests With Maven

Explore how to execute Selenium automated tests locally using Maven commands. Learn to clean the environment, run tests, generate execution reports, and selectively run test groups to streamline test management.

It has already been mentioned in the Project Information section (of the Selenium Automation Project chapter) that the project uses Maven for managing dependencies.

The dependencies are described in the pom.xml file:

XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>selenium</groupId>
<artifactId>selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>selenium</name>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>

Maven can do much more than managing dependencies. It also allows you to compile the automation code and execute the automated tests.

Two Maven commands are needed for these purposes.

mvn clean

mvn clean cleans up the target ...