jmeter-eclipse源码启动调试

大家都知道jmeter是一款很好的测试工具,但难免有时候因为业务的需要不能满足,这时候就需要我在此基础上改动点什么来帮助更好,更快的测试。网上也找了很多资料,单总不全,最近刚好整理完,特此做一个记录方便后续使用,同时也献给一些有需要的同行朋友。此例以官方2.12版本为基础: 

1.下载源码和可执行文件 

移步apache官网:http://jmeter.apache.org/ 

Apache JMeter 2.12 (Requires Java 6 or later) 
Binaries 
md5 
Source

 

2.解压 

apache-jmeter-2.12_src.zip,将apache-jmeter-2.12.zip压缩文件lib下的jar包解压至apache-jmeter-2.12_src.zip解压后的lib文件夹,为执行jmeter所需jar包,并在此lib目录中创建ext,api,junit三个文件夹,后期ant编译需要这些文件夹。 

J meter 
apache-jmeter-2.12 lib 
Junit 
a a rea d me.txt 
avalon-framework-4.I.4jar 
b sf-2.4.Oja r 
bsh-2.Ob5jar 
bshclientjar 
commons -codec- I .gja r 
commons -col lections -3.2. I ja r 
commons-httpclient-3.I ja r 
commons-io-2.4.iar 
2014/12/28 13:17 
2014/12/28 13:17 
2014/12/28 13:17 
2014/11/5 20:17 
2014/11/5 20:17 
2014/11/5 19:59 
2014/11/5 19:59 
2014/11/5 19:59 
2014/11/5 20:12 
2014/11/5 19:59 
2014/11/5 19:59 
2014/11/5 19:59 
2014/11/5 19:59 
JAR 
JAR 
JAR 
JAR 
JAR 
JAR 
JAR 
JAR

 

3.eclipse创建java工程 

命名jmeter2.12,并修改Output目录 

Cmt. a Jm 
a in cr 'n an exterTGl 
@ us ult 
C) sp«ific IRE: 
default IRE 
cr.nfia„re 
Build 
Build Path 
build gath 
c retim 
and 
Source folder name: 
output name: 
as default by

 

4.导入除src目录以外的所有jmeter源码中文件 

工程--右键---import---File system弹出如下对话框,注意先不要导入src文件 

 

File system 
Import resources from the local file system. 
From directory: G:\jmeter\apache-jmeter-2.12 
bin 
extras 
lib 
@ licenses 
test 
Into folder: jmeter 
Options 
Overwrite existing resources without warning 
Create top-level folder 
Adva nced > > 
build.properties 
Ebuild.xml 
@ checkstyle.xml 
eclipse.classpath 
eclipse. readme 
@ fb-csv.xsl 
@ fb-excludes.xml 
D LICENSE 
8 row sem 
8 rowsem

 

导入完成后,注意查看lib目录结构,如没有ext,api,junit等文件夹需要创建这些文件夹,ext文件为存放ant编译jmeter源码后的jar文件 

meter 
'RE System Library [JavaSE-I.6] 
bin 
extras 
lib 
opt 
a a read me.txt 
avalon-framework-4.I.4jar 
bsf-2.4.Oja r 
bsh-2.Ob5jar

 

5.导入src下文件 

工程名下src目录上右键---import---File system 

From directory: 
@ components 
core 
@ examples 
functions 
iorphan 
junit 
@ monitor 
A i 18nedit.properties 
8 row sem 
8 rowsem 
Into folder: jmeter/src 
Options 
Overwrite existing resources without warning 
Create top-level folder 
Adva nced > >

 

完成后目录结构,src报错是因为缺少jar包以及.classpath文件需要重新配置 

meter 
components.org.apachejmeter 
core.org.a pa che j meter 
examples.org.apachejmeter.exam 
functions.org.apachejmeter.functi 
iorphan.org.apache 
i unit 
EB monitor 
protocol 
reports.org.a pache j meter 
i18nedit.properties 
'RE System Library [JavaSE-I.6] 
bin 
extras 
lib 
B licenses 
test 
B xdocs 
build.properties 
build.xml 
@ checkstyle.xml 
eclipse.classpath 
eclipse. readme

 

6.jar包导入 

工程名右键---build Path----Configure build path弹出对话框 

type filter text 
Builders 
Jua guild path 
Properties tor Jmeter 
Java Build Path 
Source projects 
Order and Export 
JARS and build 
> avalon-framework-4.I,4.jar - jmeter/lib 
to be added to pathu 
type filter 
settings 
bin 
build 
t) B opt 
licenses 
src 
test 
XdOCS 
x I a"path 
j meter/ 
r/lib 
r/lib 
Add External 
Add 
Add Cla" 
Add Extemal Class 
Edit... 
Migrate JAR

 

7.修改.classpath文件 

将eclipse.classpath中的文件内容拷贝至.classpath文件中,重启eclipse 

Jmeter 
'RE System Library 
re6] 
src/components 
src/core 
src/examples 
src/fu nctions 
src/jorphan 
src/junit 
src/monitor/components 
src/monitor/model 
src/protocol/ftp 
src/protocol/http 
src/protocol/java 
src/protocol/jdbc 
src/protocol/jms 
src/protocol/ldap 
src/protocol/mail 
src/protocol/mongodb 
src/protocol/native 
src/protocol/tcp 
src/reports 
test/src 
Referenced Libraries 
extras 
lib 
B licenses

 

到此步骤,还缺少jar如下: 

下载地址:http://polydistortion.net/bc/download/,下载对应的jar包 

59 
59 
bcpkix-jdkl Son 
bcorov-idkl Son 
bcmail-jdk150n-I •g.jar - (missil 
-149jar - 
-1.49.iar - 
(missilLLLLLLL 
(missi

 

8.ant编译 

eclipse都已自带ant环境,设置jmeter工程ant编译 

工程名 右键---properties弹出选项框 

 

点击new选项,弹出编译对话框选择ant builder 

'pe filter text 
Resou rce 
Builders 
Checkclipse 
Java Build Path 
Java Code Styl 
Java Compiler 
Java Editor 
Javadoc Locati 
Project Facets 
Project Refere 
Run/Debug 
Server 
Ta sk Reposito 
Task Tags 
Validation 
Wi kiText 
Choose an external tool type to create: 
Ant Builder 
Prog ra m 
Importm 
Edit... 
R em ave 
up 
Down 
Ca ncel

 

弹出ant配置选项 

Edit launch configuration prope•ties 
a cnfguraticn that will mn an Ant build fle during 
a build. 
Refrzkl Targets 00 Build 
Buildfle 
S r ild l) 
Note an æntaining using C). 
Set an Input

 

9.执行ant编译 

在工程目录下找到build.xml文件---右键---Run As--->ant build  

丷 - 一 nses 
丷 Referenced Libraries 
丷 test src 
丷 src/repo 
丷 src/protocol/tcp 
丷 pr 。 t 。 8- nat 一 
丆 
bu = d.pro 
fb-excludesxm 
checkstylexml 
fb-csv.xsl 
eclipse.readme 
eclipse.classpath 
xdocs 
test 
README 
NOTICE 
LICENSE 
build.xml

 

编译大致结果: 

[Ant Build] -—2uw-03) 
Ci_ac] 
Cig_c] 
acka e: 
install: 
building 
Buildi ng 
Buildi ng 
Building 
Buildi 
Building 
Buildi ng 
Jar: 
jar 
Jar. : 
Jar: 
t: xstuay \ApacneJmeter 
laap . Jar• 
E : \ApacheWeter 
mail. jar 
E : udy cp. j r 
E : 1st udy jar 
E : \ Iib\ext \ApacheJPIeter_ 
. Jar 
E : \ApacheWet er 
mongodb . jar 
E . jar 
BUILD SUCCESSFUL 
Total time: 4 seconds

 

10.debug启动jmeter 

找到org.jmeter.NewDriver类---右键----Debug As----Debug Configurations 

Creatq manage, and run configurations 
Debug a 
Eclipse Application 
Eclipse Data Tools 
G e-«ic Serær 
G mic Server(Exte r 
H TTP 
B Preview 
Applet 
New Drive r 
Java Applicati 
NewDriver (1) 
JU JLlnit 
'Unit plug-in Test 
Maven Build 
OSGi 
Pete Appli 
Remote JavaScript 
Rhino JavaScript 
JD Task TUt 
XSL 
23 of 24 • 
Name; NewDriver (l ) 
@ Main 
JRE Cl.wpath sc e 
A re u rw-vt 
VM a 
Wor king directory: 
C) Defaulv 
@ Othe 
rks n) 
Varia b I 
App I Y

 

配置完成debug就可以看到熟悉的jmeter画面 

然后,尽情的享受jmeter调试,各种需要改动吧。。。 

 

 

posted @ 2017-11-28 11:53  春田花花同学会  阅读(191)  评论(0编辑  收藏  举报