1. Install Maven
2. Installing testng
3. Configure Maven's dependency, and build
<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>testnggroup</groupId> <artifactId> Testngartifact</artifactid> <version>0.0.1-SNAPSHOT</version> <packaging>jar</ Packaging> <name>testngartifact</name> <url>http://maven.apache.org</url> < Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </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> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</ Target> <compilerArgs> <arg>-Xlint:unchecked</arg> <arg>-xlint:deprecation </arg> <!--<arg>endorseddirs=${endorsed .dir}</arg>--> </compilerArgs> </configuration> </plu gin> <!--add Plug-in association Testng.xml-<plugin> <groupid>org.apache.ma Ven.plugins</groupid> <artifactId>maven-surefire-plugin</artifactId> <v Ersion>2.5</versioN> <configuration> <testFailureIgnore>true</testFailureIgnore> <suiteXmlFiles> <file>res/testNG.xml</file> < ;/suitexmlfiles> <!--<workingDirectory>target/</workingDirectory>--> </configuration> </plugin> </plugins> </build></project>
4. Create Res folder, create Testng.xml
<?xml version= "1.0" encoding= "Utf-8"? ><suite name= "Testproj" parallel= "false" > <test name= " TestDemo1 "> <classes> <class name=" Simpletest.java "></class> </classes> </test></suite>
5. Open the command line in Eclipse, enter: mvn-f pom.xml clean Test-dxmlfilename=testng.xml
Maven+testng+eclipse