Maven+TestNG+ReportNG/Allure接口自动化测试框架初探(上)




|
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
|












|
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<xmlFileName>testng.xml</xmlFileName>
</properties>
|
|
<!-- testNG依赖管理 -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>2.0.9</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 依赖Guice -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.64</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.10</version>
</dependency>
|
|
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>
src/test/resources/${xmlFileName}
</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<workingDirectory>target/</workingDirectory>
<forkMode>always</forkMode>
<!-- 解决报告中中文乱码 -->
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
</plugins>
</build>
|





|
package com.test.pub;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import jxl.Workbook;
import jxl.Sheet;
import jxl.Cell;
public class ExcelUtils {
public static Map <String, HashMap> excelToHashMapByFirstSheet(String fPath, String sheetName){
try{
File fExcel = getExcelFileObj(fPath);
Workbook wb = Workbook.getWorkbook(fExcel);
Sheet sht = wb.getSheet(sheetName);
int rowCount = sht.getRows();
int colCount = sht.getColumns();
Cell cel = null;
Map <String, HashMap> excelContents = new HashMap();
if(rowCount<=2){
System.out.println("无测试案例");
return null;
}else{
//检查是否存在空行
String rowContents = "";
for(int i=2;i<rowCount;i++){
if(sht.getCell(0, i).getContents().toString().length()==0){
System.out.println("测试案例文件中存在空行");
return null;
}else{
for(int j=0;j<colCount;j++){
rowContents = rowContents + sht.getCell(j, i).getContents().toString();
}
if (rowContents.length()<20){
System.out.println("测试案例文件中存在空行");
return null;
}
}
}
}
//开始读取内容
for(int rowIndex=2;rowIndex<rowCount;rowIndex++){
HashMap<String, String> rowMap = new HashMap();
String testCaseCode = sht.getCell(0, rowIndex).getContents().toString();
for(int colIndex=1;colIndex<colCount;colIndex++){
rowMap.put(sht.getCell(colIndex, 1).getContents().toString(), sht.getCell(colIndex, rowIndex).getContents().toString());
}
excelContents.put(testCaseCode, rowMap);
}
wb.close();
//HashMap<String, String> tmpMap = new HashMap();
//tmpMap.put("count", "" + (rowCount-2));
//excelContents.put("testsCount", tmpMap);
return excelContents;
}catch (Exception e){
System.out.println("发生异常:" + e);
}
return null;
}
public static File getExcelFileObj(String fPath){
try{
File fExl = new File(fPath);
return fExl;
}catch (Exception e){
System.out.println(e);
}
return null;
}
}
|


Maven+TestNG+ReportNG/Allure接口自动化测试框架初探(上)的更多相关文章
- 基于maven+java+TestNG+httpclient+poi+jsonpath+ExtentReport的接口自动化测试框架
接口自动化框架 项目说明 本框架是一套基于maven+java+TestNG+httpclient+poi+jsonpath+ExtentReport而设计的数据驱动接口自动化测试框架,TestNG ...
- API 接口自动化测试框架
转自: https://testerhome.com/topics/3455 前言 接口自动化逐渐成为各大公司投入产出最高的测试技术.但是如何在版本迅速迭代过程中提高接口自动化的测试效率,仍然是大部分 ...
- 接口自动化测试框架【windows版】:jmeter + ant + jenkins
为了提高回归效率及保证版本质量,很多公司都在做自动化测试,特别是接口自动化.接口自动化测试框架很多,有写代码的,也有不写代码的,我觉得没有谁比谁好,谁比谁高级之说,只要适用就好. 今天给大家分享一个不 ...
- 接口测试入门(4)--接口自动化测试框架 / list和map用法 / 随机选取新闻 (随机数生成) / 接口相关id映射
一.接口自动化测试框架 为了更好的组织测试方法,测试用例并且持续集成,我们选择了 java+testNG(测试用例组织)+gitlab(代码版本管理)+Jenkins(持续集成工具) 作为一整套的自 ...
- 性能测试学习之路 (四)jmeter 脚本开发实战(JDBC &JMS &接口脚本 & 轻量级接口自动化测试框架)
1.业务级脚本开发 登录脚本->思路:在线程组下新建两个HTTP请求,一个是完成访问登录页,一个是完成登录的数据提交. 步骤如下: 1) 访问登录页 2) 提交登录数据的HTTP PS:对于 ...
- ApiTesting全链路接口自动化测试框架 - 新增数据库校验(二)
在这之前我完成了对于接口上的自动化测试:ApiTesting全链路接口自动化测试框架 - 初版(一) 但是对于很多公司而言,数据库的数据校验也尤为重要,另外也有小伙伴给我反馈希望支持. 所以最近几天我 ...
- python版接口自动化测试框架源码完整版(requests + unittest)
python版接口自动化测试框架:https://gitee.com/UncleYong/my_rf [框架目录结构介绍] bin: 可执行文件,程序入口 conf: 配置文件 core: 核心文件 ...
- 接口自动化 [授客]基于python+Testlink+Jenkins实现的接口自动化测试框架V3.0
基于python+Testlink+Jenkins实现的接口自动化测试框架V3.0 by:授客 QQ:1033553122 博客:http://blog.sina.com.cn/ishou ...
- 接口自动化 基于python+Testlink+Jenkins实现的接口自动化测试框架[V2.0改进版]
基于python+Testlink+Jenkins实现的接口自动化测试框架[V2.0改进版] by:授客 QQ:1033553122 由于篇幅问题,,暂且采用网盘分享的形式: 下载地址: [授客] ...
随机推荐
- react native redux saga增加日志功能
redux-logger地址:https://github.com/evgenyrodionov/redux-logger 目前Reac native项目中已经使用redux功能,异步中间件使用red ...
- Ubuntu 18.04安装 Sublime
作为一款强大的源代码编辑器,当然需要一手流利的命令来安装它. 命令: wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | s ...
- ubuntu下基于Anaconda使用Tensorflow
为了在ubuntu下利用Anaconda使用tensorflow,但在利用conda安装tensorflow,不能在终端,spyder和notebook中直接使用,需要我们进行一定的配置. 1.安装A ...
- 【前端必备】二、CSS篇
1.CSS盒模型 当对一个文档进行布局的时候,浏览器的渲染引擎会根据盒模型将所有元素表示为一个个矩形的盒子,CSS 决定这些盒子的大小.位置以及属性(例如颜色.背景.边框尺寸-) 每个盒子有4个区域: ...
- go chapter 2 - read file(yaml)
func main() { data, err := ioutil.ReadFile("D:/test/widua.go") if err != nil { fmt.Println ...
- Codeforces Round #113 (Div. 2) Tetrahedron(滚动DP)
Tetrahedron time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- UFO长啥样?--Python数据分析来告诉你
前言 真心讲,长这么大,还没有见过UFO长啥样,偶然看到美国UFO报告中心有关于UFO时间记录的详细信息,突然想分析下这些记录里都包含了那些有趣的信息,于是有了这次的分析过程. 当然,原始数据包含的记 ...
- [Codeforces-div.1 55D] Beautiful numbers
[Codeforces-div.1 55D] Beautiful numbers 试题分析 还是离散化...\(f_{i,j,k}\)表示i位,gcd为j,余数为k. #include<iost ...
- BZOJ 3594 [Scoi2014]方伯伯的玉米田(二维树状数组)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3594 [题目大意] 给出一个数列,选出k个区间使得区间内数全部加1, 求k次操作之后最 ...
- mysqldumper
介绍 MySQL自身的mysqldump工具支持单线程工作,依次一个个导出多个表,没有一个并行的机,这就使得它无法迅速的备份数据. mydumper作为一个实用工具,能够良好支持多线程工作,可以并行的 ...