How to execute TestNG regression suite from Maven commands
Step 1. Create TestNG tests eg.
import org.testng.annotations.Test;
public class testClass {
@Test
public void myFunction() {
System.out.println(“Testing 123……”);
}
}
Step 2: Configure surefire plugin in TestNG.xml as follow:
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>
<groupId>com.TestNGE</groupId>
<artifactId>testNGExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<jre.level>1.7</jre.level>
<jdk.level>1.7</jdk.level>
</properties>
<dependencies>
<!– https://mvnrepository.com/artifact/org.testng/testng –>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!– Compiler plug-in –>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.level}</source>
<target>${jdk.level}</target>
</configuration>
</plugin>
<!– Below plug-in is used to execute tests –>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Step 3: run pom.xml (as per step2) via Maven -> test
0 comments