How to write a JMeter test for Java Request

前端 未结 3 1617
不思量自难忘°
不思量自难忘° 2020-12-09 00:11

I need to do load testing on in memory databases.

I want to use JMeter and am under the impression I need to write a class that implements JavaSamplerClient.

3条回答
  •  Happy的楠姐
    2020-12-09 00:38

    Your custom class needs either implement JavaSamplerClient or to extend AbstractSamplerClient.

    The absolute minimum is runTest() method implementation.

    I'd recommend to look into sources for existing JavaTest and SleepTest Java Request samplers:

    • /src/protocol/java/org/apache/jmeter/protocol/java/test/JavaTest.java
    • /src/protocol/java/org/apache/jmeter/protocol/java/test/SleepTest.java

    Sources are available from JMeter download page

    Or there is a couple of guides which have example of simple working Java Requests.

    See

    1. Beanshell vs JSR223 vs Java JMeter Scripting comparison benchmark - for something very basic like generating large random string
    2. WebSocket Testing With Apache JMeter - for fully functional Websocket client implementation via Java Request

    After compiling your classes package it to .jar and drop to /lib/ext folder of your JMeter installation. Your class should be available from Java Request drop down.

    Hope this helps.

提交回复
热议问题