1、ant自身缺陷,返回结果中有特殊字符,乱码字符,无法识别,jtl文件转换时报错。

2、jtl文件过大转换成html文件时出现内存溢出。

针对以上情况:可考虑使用BeenShell Sampler:对返回结果的乱码、特殊字符进行处理,返回结果内容过大,通过代码进行截取,但是会对性能测试结果又小许影响。

引入的外部java文件代码如下:

import java.net.URI;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;

public class GetRequest {
public static String doGet(String url, String keyValueParam,String proxy,String port){
// 构建htpp客户端对象
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet();
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(20000)
.setConnectTimeout(20000)
.setConnectionRequestTimeout(20000)
.build();
if(!proxy.equals("")){
requestConfig = RequestConfig.custom()
.setSocketTimeout(20000)
.setConnectTimeout(20000)
.setConnectionRequestTimeout(20000).setProxy(new HttpHost(proxy, Integer.valueOf(port)))
.build();
}

get.setConfig(requestConfig);
// 将url和键值对参数拼接成新的url地址
get.setURI(URI.create(url + keyValueParam));
HttpResponse response;
String strResponse ="No HttpResponse";
try {
response = client.execute(get);
// 获取返回主体
strResponse = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
strResponse ="Send Request,But HttpResponse is error";
}finally {

try {
client.close();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}

}

return strResponse;
}

public static String doGet(String url, String keyValueParam, String header,String proxy,String port){
// 构建htpp客户端对象
CloseableHttpClient client = HttpClientBuilder.create().build();

HttpGet get = new HttpGet();
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000)
.setConnectionRequestTimeout(20000).build();
if (!proxy.equals("")) {
requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000)
.setConnectionRequestTimeout(20000).setProxy(new HttpHost(proxy, Integer.valueOf(port))).build();
}
get.setConfig(requestConfig);
// 将url和键值对参数拼接成新的url地址
get.setURI(URI.create(url + keyValueParam));
get.addHeader("Cookie", header);

HttpResponse response;
String strResponse="No HttpResponse";
try {
response = client.execute(get);
strResponse = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
strResponse="Send Request,But HttpResponse is error";
}finally {

try {
client.close();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}

}
// 获取返回主体

return strResponse;
}
}

BeenShell  Sampler的代码如下:

source("D:/Jmeter/运营平台核心性能场景/java/GetRequest.java");
String actualResponse = GetRequest.doGet("${Agreement}://${Host}:${Port}","${qualityCertificationUrl}","${Cookie}","${ProxyHost}","${ProxyPort}");
String sonStr= "<h3>初级认证2.0</h3>";
String response="";
//判断是否包含期望的字符串
if(actualResponse.indexOf(sonStr)!=-1){
response = "<h3>初级认证2.0</h3>";
}else{
response = actualResponse;
}
//为jmeter响应结果赋值
ResponseMessage=response;

关于jmeter+ant+jenkins性能自动化将测试结果文件jtl转换成html文件遇到的问题。的更多相关文章

  1. Jmeter+ant+Jenkins接口自动化框架搭建

    摘自:https://testerhome.com/topics/13389 一.背景  上一篇讲了Jmeter 接口自动化-脚本数据分离实例,我们知道怎么利用Jmeter去编写接口自动化脚本,但是接 ...

  2. jmeter+ant+jenkins实现自动化接口测试

    一.安装前准备 1.JDK:jdk-8u121-windows-x64 2.jmeter工具:apache-jmeter-2.13 3.ANT工具:apache-ant-1.9.7-bin 4.jen ...

  3. Jmeter+Ant+Jenkins接口自动化框架

    最近应公司要求,搭建一套接口自动化环境.看到通知邮件,没有多想就确定了Jmeter路线.可能有些人会 说,为啥不用python,相对而言高大上一些.因为公司内部现在项目有用到Jmeter,正好可以结合 ...

  4. Jmeter+Ant+Jenkins接口自动化持续集成环境搭建(Linux)

    一.安装说明 系统环境:CentOS release 6.4 JDK版本:jdk1.8.0_181 Jmeter版本:apache-jmeter-3.0 Ant版本:apache-ant-1.9.13 ...

  5. jmeter+ant+jenkins接口自动化环境搭建

    一.准备   1.安装jdk  --->点击查看安装教程 2.安装jmeter  ,官网下载jmeter解压,配置jmeter环境: JMETER_HOME (解压jdk路径) Path (;% ...

  6. Jmeter+Ant+Jenkins 接口自动化之简单demo

    之前的文章我们已经分享过了 Jmeter+Ant 的批量执行 ,并且搭建好了Jenkins部署平台,如何再将三者完美结合呢? 1.首先打开Jenkins主页面,进入“系统管理-插件管理”,安装相关的插 ...

  7. jmeter+ant+jenkins的自动化接口测试

    一.Jenkins安装配置 1.安装配置JDK1.7+环境变量: 2.下载jenkins.war,放入D:\jenkins目录下,目录位置随意: Jenkins启动方法: cmd进入Jenkins目录 ...

  8. 关于Jmeter+Ant+Jenkins作为接口、性能自动化框架的误区

    说明:Apach-Jmeter有完善的桌面客户端,关联数据的处方方式,各种参数化的方式,各种Jar包的扩展,也可以用作抓包工具使用,当然最重要的是它是[开源!开源!开源!],重要的事说三遍,目前也有基 ...

  9. 【此处有干货~】jmeter+ant+jenkins持续集成配置及过程中问题解决思路

    本人是一枚工作近三年的小测试,大学正好专业为软件测试,在工作中用到最多的是功能测试.接口测试.压力测试.偶尔会涉及到性能测试......(小白,很多观念技术跟大佬差距太大,勿喷) 在接口测试过程当中, ...

随机推荐

  1. P1351 联合权值[鬼畜解法]

    题目描述 无向连通图 G 有 n 个点,n−1 条边.点从 1 到 n 依次编号,编号为 i 的点的权值为 Wi​,每条边的长度均为 1.图上两点 (u,v) 的距离定义为 u 点到 v 点的最短距离 ...

  2. 洛谷P2221 高速公路【线段树】

    题目:https://www.luogu.org/problemnew/show/P2221 题意:有n个节点排成一条链,相邻节点之间有一条路. C u v val表示从u到v的路径上的每条边权值都加 ...

  3. vuex的使用介绍

    1.vuex是什么? vuex是一个专为vue.js应用程序开发的状态管理模式(它采用集中式存贮管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化). 2.vuex的核心概念? ...

  4. 十五.DNS子域授权、分离解析、缓存DNS服务器

    1.搭建基本DNS服务器 pc7: 1.1 安装软件包 ]# yum -y install bind-chroot bind bind         //域名服务包 bind-chroot  //提 ...

  5. 通过 Ajax 调取后台接口将返回的 json 数据绑定在页面上

    第一步: 编写基础的 html 框架内容,并引入 jquery: <!doctype html> <html lang="en"> <head> ...

  6. 【原创】sed正则表达式替换

    1.数字替换原数字 sed -i "s/\([0-9]*\)/\1/g"

  7. nasm汇编讲解

    一.什么是nasm汇编 nasm使用在windows.linux等系统下的汇编. 二.语法介绍 2.1 nasm 是区分大小写 例如:符号 foo 与 FOO 是两个不同的标识符. 2.2 内存操作数 ...

  8. EASYUI赋值和取值

       $("#ajname").textbox("setValue",name);      $("#jyzjg").combobox(&q ...

  9. Bsgs模板

    模板最主要的是自己看得舒服,不会给自己留隐患,调起来比较简单,板子有得是,最主要的是改造出适合你的那一套.                  ——mzz #include<bits/stdc++ ...

  10. DELPHI搭建centos开发环境

    DELPHI搭建centos7开发环境 关闭防火墙 搭建开发环境,还是直接关闭LINUX防火墙,省事. 否则,使用到的网络端口号,都要在防火墙开放,麻烦. systemctl disable fire ...