使用性能测试工具JMeter系列2-运行JUnit Request测试Java API

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

核桃博客 转载,http://www.hetaoblog.com/?p=56

使用性能测试工具JMeter系列2-运行JUnit Request测试Java API

之前在使用性能测试工具JMeter来测试网站性能1 介绍了使用JMeter的基本使用方式和用来测试网站性能的过程,这里介绍通过使用JMeter的JUnit Request来做Java API的并发性能测试;

在JMeter 2.1.2后,JMeter增加了JUnit Sampler的功能;这样,JMeter就可以调用用JUnit写的Test Case了,通过访问JUnit的测试代码,间接完成对Java API的性能测试(事实上,JMeter也支持直接对Java API测试,不过貌似没有对JUnit的测试来的方便)。下面是主要步骤:

1.     将自己的JUnit测试项目打包成一个完整的Jar,放到JMeter的lib/junit目录下

2.     建立如下图所示测试计划,在JMeter中建立JUnit Request和一种查看结果的方式(比如这里的表格查看结果的方式后),

其中,JUnit Request的页面上,可以选择要测试的类,这里的com.hetaoblog.api.test.APIManagerTest就是我自己放在lib/junit目录下的jar包中的测试代码,在下面还可以选择要测试的函数和其他参数

  1. 设置好测试计划后,就想做普通的JMeter测试一样,点击运行->启动,然后再点击用表格查看结果,就可以看到类似下面的结果:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值