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 由于篇幅问题,,暂且采用网盘分享的形式: 下载地址: [授客] ...
随机推荐
- 不同版本的jquery的复选框checkbox的相关问题
在尝试写复选框时候遇到一个问题,调试了很久都没调试出来,极其郁闷: IE10,Chrome,FF中,对于选中状态,第一次$('#checkbox').attr('checked',true)可以实现 ...
- 洛谷P3197 HNOI2008 越狱
题目传送门 实际上昨天大鸡哥已经讲过这题了,结果没记住,今天一道相似的题就挂了......吃一堑长一智啊. 思路大致是这样:如果直接算发生越狱的情况会比较复杂,所以可以用间接法,用安排的总方案-不会发 ...
- 差分【bzoj3043】IncDec Sequence
Description 给定一个长度为n的数列{a1,a2...an},每次可以选择一个区间[l,r],使这个区间内的数都加一或者都减一. 问至少需要多少次操作才能使数列中的所有数都一样,并求出在保证 ...
- HDU 6065 RXD, tree and sequence (LCA DP)
RXD, tree and sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java ...
- Oracle unique / distinct
[唯一]DISTINCT与UNIQUE的“区别” 今天一个朋友在Oracle中偶然发现UNIQUE也可以得到唯一的数据结果,问到DISTINCT与UNIQUE的区别.答案是:他们没有区别! d ...
- WebDAV服务漏洞利用工具DAVTest
WebDAV服务漏洞利用工具DAVTest WebDAV是基于Web服务的扩展服务.它允许用户像操作本地文件一样,操作服务器上的文件.借助该功能,用户很方便的在网络上存储自己的文件.为了方便用户使 ...
- ES5 Object.defineProperty 方法
先看一个例子: var o = {}; o.a = 1; // 等待于: Object.defineProperty(o, 'a', { value: 1, writable: true, confi ...
- bzoj 2803 [Poi2012]Prefixuffix 兼字符串hash入门
打cf的时候遇到的问题,clairs告诉我这是POI2012 的原题..原谅我菜没写过..于是拐过来写这道题并且学了下string hash. 字符串hash基于Rabin-Karp算法,并且对于 ...
- Android Studio自动化快速实现Parcelable接口序列化
1.在线安装 然后打开File -> Settings -> Pugins -> Browse Repositories 如下,输入android parcelable code g ...
- Problem A: 零起点学算法80——逆序输出(数组练习)
#include<stdio.h> int main() { ]; scanf("%d",&n); ;i<=n;i++){ scanf("%d& ...