-
文章可能会有纰漏,希望路过大神可以指点,在此感激不尽!
-
大家可能注意我的项目是中文的,因为我用了汉化版的一个插件,如果需要可自行下载,安装后重启就可以了
一.安装配置testng
1、根据自己需要配置testng的jar包:https://mvnrepository.com/artifact/org.testng/testng
2、File -> Project Structure... -> Modules -> Dependencies -> Add JARs or directories 添加testng-7.0.0.jar -> Apply -> OK
3、创建测试用例
可参照我这篇文章:https://blog.csdn.net/weixin_38337769/article/details/102901676
4、根据截图步骤,添加配置testng
5、执行结果
6、生成testngxml文件
File-Settings-Plugins-Marketplace-搜索Create TestNG XML 插件
7、产生testng.xml文件
二、testng本身带的测试报告比较丑,所以使用了reportng
1、pom文件引入reportng、guice依赖,可自行粘贴引入
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</dependency>
2、配置reportng的jar包,jar包链接:https://mp.csdn.net/console/upDetailed
3、eportng 开源维护到1..1.4版本 报告地址:\aututest\test\test-output\html\index.html guice是测试报告UI界面