首先,使用maven结合testng文件时,需要在pom文件中添加
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>(此处要注意一定是需要写你的testng的路径,否则会出错)
</suiteXmlFiles>
</configuration>
</plugin>