maven项目,把testng用例放在test目录下,配置pom.xml 文件如下,执行mvn test 能自动执行testng里面的用例。
pom文件配置<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.testing</groupId> <artifactId>testNGPO</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>testNGPO</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <allure.version>2.13.4</allure.version> <aspectj.version>1.9.5</aspectj.version> <suiteXmlFile>testng.xml</suiteXmlFile> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.10</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-api</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-junit5</artifactId> <version>2.13.6</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.25</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <!-- maven构建插件,运行mvn test调用allure实现测试报告生成 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> <!-- 指定要执行的testng路径 --> <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> <systemProperties> <property> <!-- 配置 allure 结果存储路径 --> <name>allure.results.directory</name> <value>${project.build.directory}/allure-results</value> </property> </systemProperties> <!-- 出现测试异常是否继续向下执行,此选项必备,防止异常测试场景导致执行中断 --> <testFailureIgnore>true</testFailureIgnore> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
使用mvn clean test执行,执行的是配置在pom.xml里testng.xml的测试用例
标签:allure,testng,maven,测试用例,test,org,aspectj,mvn From: https://www.cnblogs.com/ixtao/p/17675802.html