Java+TestNG+Maven+Excel+IDEA接⼝⾃动化⼊门(⼀)环境配置前置:
1.本机环境安装了maven并配置环境变量
2.本机环境安装了IDEA软件
3.本机环境安装了Java jdk 8版本
4.有⼀定java和maven基础
因为以上⽹上例⼦很多,就不再重复赘述了
⼀、新建maven项⽬,在⽣成的l中配置所需jar包
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0"
xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId&le</groupId>
<artifactId>Test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId&stng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-serialization-fastjson</artifactId>
<version>2.6.7</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.24</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId&stng</groupId>
<artifactId>testng</artifactId>
</exclusion>
java环境变量自动配置</exclusions>
</dependency>
<dependency>
<groupId&le.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.hynnet</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<!--这⾥设置关联的l路径,项⽬根⽬录下的res⽂件夹⾥⾯-->
<suiteXmlFiles>
<file&l</file>
</suiteXmlFiles>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>portng.HTMLReporter</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
</project>
此时右下⾓会弹出提⽰,选择“Import Changes”,会⾃动下载依赖
接下来要做的就是等它下载完成。
⼆、⽣成l
File->Settings-Plugins  下载Create TestNG XML 插件,重启IDEA即可。
打开l
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "/testng-1.0.dtd" > <suite name="Suite1">
<!-- 测试名称会在报告中显⽰-->
<test name="Get⽅法测试" verbose="2">
<classes>
<!--运⾏的test类名称-->
<class name="GetDemo"/>
</classes>
</test>
<test name="Post⽅法测试" verbose="2">
<classes>
<class name="PostDemo"/>
</classes>
</test>
</suite>
⾄此所有配置完成

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。