Jmeter ExcelDataPreProcessor
Jmeter的预处理器主要是用来在采样器(sample)被执行之前做一些额外的工作,比如参数化等等。
本文写一个例子来说明如何增加一个预处理器,需求如下:我们想在执行采样器前读取Excel文件中的数据作为参数,此预处理器可以配合While循环控制器使用,每次循环读取excel中的一行数据。
@GUIMenuSortOrder(5)
public class ExcelDataPreProcessor extends AbstractTestElement implements
Cloneable, PreProcessor, TestBean {
private static final Logger log = LoggerFactory
.getLogger(ExcelDataPreProcessor.class); private String filename = ""; // file to source (overrides script) private static final long serialVersionUID = 233L; @Override
public void process() {
//做你想做的一些逻辑
System.out.println(this.getFilename());
} public String getFilename() {
return filename;
} public void setFilename(String filename) {
this.filename = filename;
} @Override
public Object clone() {
return super.clone();
}
}
2、写一个对应的Bean
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/ package org.apache.jmeter.modifiers; import java.beans.PropertyDescriptor;
import java.util.ResourceBundle; import org.apache.jmeter.testbeans.BeanInfoSupport;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testbeans.gui.FileEditor; public class ExcelDataPreProcessorBeanInfo extends BeanInfoSupport { public ExcelDataPreProcessorBeanInfo() {
this(ExcelDataPreProcessor.class,null);
} public ExcelDataPreProcessorBeanInfo(Class<? extends TestBean> beanClass, String[] languageTags) {
this(beanClass, languageTags, null);
} protected ExcelDataPreProcessorBeanInfo(Class<? extends TestBean> beanClass, String[] languageTags, ResourceBundle rb) {
super(beanClass);
PropertyDescriptor p; p = property("filename"); // $NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, ""); // $NON-NLS-1$
p.setPropertyEditorClass(FileEditor.class); createPropertyGroup("filenameGroup", // $NON-NLS-1$
new String[] { "filename" }); // $NON-NLS-1$ } }
这个是描述界面布局和相关元素的的
3,在saveservice.properties文件中增加配置:
ExcelDataPreProcessor=org.apache.jmeter.modifiers.ExcelDataPreProcessor
4、增加一个(ExcelDataPreProcessorResources.properties)多语言支持:
Jmeter ExcelDataPreProcessor的更多相关文章
- jmeter之线程组的使用
线程组 在使用jmeter性能测试时,我们都得先添加个线程组,右键testplan-->添加-->Threads-->线程组.在线程组下执行. 问题:为了能够让jmeter在做性能测 ...
- 从Fiddler抓包到Jmeter接口测试(简单的思路)
备注:本文为博主的同事总结的文章,未经博主允许不得转载. Fiddler下载和配置安装 从网上下载fiddler的安装包即可,直接默认,一直点击下一步,直至安装完成. 安装完成后直接打开Fiddler ...
- Jmeter正则表达式
Jmeter正则表达式 文章转自:http://www.cnblogs.com/jamesping/articles/2252675.html 正则表达式可以帮助我们更好的描述复杂的文本格式.一旦你描 ...
- Jmeter安装与环境部署
Jmeter安装与环境部署 版权声明:本文为博主原创文章,未经博主允许不得转载. 博主:海宁 联系:whnsspu@163.com
- JMeter压力测试
Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试但后来扩展到其他测试领域. 它可以用于测试静态和动态资源例如静态文件. ...
- 压力测试之badboy和Jmeter的简单使用方法
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 所谓压力测试是指,通过确定一个系统的瓶颈或者不能接收的性能点, ...
- 用jmeter通过ssl验证访问https
找了一个支付宝的网站尝试.https://memberprod.alipay.com/account/reg/index.htm 我用的是chrome,点这个小锁 如果是IE也可以在网页上右键,属性, ...
- JMeter使用文档
JMeter使用文档 1.JMeter安装步骤 1.1Windows环境 a.安装jdk(对应windows系统位数) http://www.oracle.com/technetwork/java/j ...
- jmeter之连接mysql和SQL Server配置
下载jdbc驱动 在使用jmeter做性能或自动化测试的时候,往往需要直接对数据库施加压力,或者某些参数只能从数据库获取,这时候就必须使用jmeter连接数据库. 1.下载对应的驱动包 mysql驱动 ...
随机推荐
- 【leetcode刷题笔记】Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- 51nod 1686 第K大区间2
1685 第K大区间2 定义一个区间的值为其众数出现的次数.现给出n个数,求将所有区间的值排序后,第K大的值为多少. 众数(统计学/数学名词)_百度百科 Input 第一行两个数n和k(1<=n ...
- mysql 用户和存储过程相关命令
如何显示所有的存储过程?select `name` from mysql.proc where db='db_name' and `type`='procedure';orshow procedure ...
- Python模块-logging模块(二)
logging模块记录日志有四个主要类:logger,handler,formatter,filter logger提供了应用程序可以直接使用的接口,每个程序在输出信息之前都要获得一个Logger h ...
- python操作sql server2008 pyodbc
使用Python通过PyODBC连接数据的注意事项 今天使者用PyODBC连接数据库,试了很久才出来,现把一些心得体会和大家分享! 一.PyODBC的下载地址: http://code.google. ...
- Quartz.NET+TopSelf 实现定时服务
转载http://www.cnblogs.com/jys509/p/4628926.html Quartz.NET 入门 2015-07-09 00:59 by jiangys, 67858 阅读, ...
- Sql server 备份及还原
--最常用的几种备份方法: --数据备份----------------------- --数据库级:完整数据库备份 差异数据库备份 --文件级: 完整文件备份 差异文件备份 --日志备份------ ...
- 问题:JsonConvert;结果:JSON详解
JSON详解 JSON的全称是”JavaScript Object Notation”,意思是JavaScript对象表示法,它是一种基于文本,独立于语言的轻量级数据交换格式.XML也是一种数据交换格 ...
- 关于cin
今天同学调试一个简单的程序的时候发现了问题,我们两个讨论的时候弄出了好多乐子 #include <iostream> using namespace std; int main() { ; ...
- BIOS MCSDK 2.0 User Guide - Acronyms and Definitions
BIOS MCSDK 2.0 User Guide - Texas Instruments Wiki Acronyms and Definitions The following acronyms a ...