1、创建maven项目
在pom文件中加入依赖:
![](http://upload-images.jianshu.io/upload_images/15110677-e34b86e23740415a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/768/format/webp)
2、在路径src/main/java下创建类,如类名shellclass
![](http://upload-images.jianshu.io/upload_images/15110677-60347bf69db35aff.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/774/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-7bd80d86f79c2426.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/774/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-09212930c86138e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/780/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-230b69113e710b8f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/778/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-0c8b7809cb9c693a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/771/format/webp)
3、 创建jmeter调用类,如jmtershell,完成jmetershell编写后导出成jar包。
![](http://upload-images.jianshu.io/upload_images/15110677-f8437837d4b12ace.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/780/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-49e49b6976a7751c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/776/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-ac1808226ca2a603.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/774/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-b448c30663962e33.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/778/format/webp)
3、 将shelljmeter.jar放入jmeter安装路径libext目录下;将依赖的maven包ganymed-ssh2-210-huson-1.jar放入jmeter安装路径lib路径下。
4、 在jmeter中创建java请求参数如下:
![](http://upload-images.jianshu.io/upload_images/15110677-a70dab394812c754.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
另创建 “响应断言”对程序中调用shell产生的Response message进行断言,确保shell被真正被调用。
![](http://upload-images.jianshu.io/upload_images/15110677-1cd6944b261c218b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
![](http://upload-images.jianshu.io/upload_images/15110677-6c3ee324d305010c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
小礼物走一走,来简书关注我
链接:https://www.jianshu.com/p/9041d6463de9
来源:简书