github abstracta/jmeter-java-dsl v0.9
0.9

latest releases: v1.26, v1.25.3, v1.25.2...
3 years ago

Is now possible to use Java Code without any need to specify a groovy script in JSR223 Pre & Post processors, taking full advantage of Java type safety and code auto-completion.

Here is an example:

import static org.assertj.core.api.Assertions.assertThat;
import static us.abstracta.jmeter.javadsl.JmeterDsl.*;

import java.io.IOException;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import us.abstracta.jmeter.javadsl.core.TestPlanStats;

public class PerformanceTest {

  @Test
  public void testPerformance() throws IOException {
    TestPlanStats stats = testPlan(
      threadGroup(2, 10,
        httpSampler("http://my.service")
          .children(
            jsr223PostProcessor(s -> { 
              if ("429".equals(s.prev.getResponseCode())) { 
                s.prev.setSuccessful(true); 
              } 
            })
          )
      )
    ).run();
    assertThat(stats.overall().elapsedTimePercentile99()).isLessThan(Duration.ofSeconds(5));
  }
  
}

WARNING: using this, instead of Groovy script (String), is currently only supported when using embedded JMeter engine. No support for saving to JMX and running it in JMeter GUI, or running it with BlazeMeter.

Thanks to @MrThreepwood for pushing for this support.

Don't miss a new jmeter-java-dsl release

NewReleases is sending notifications on new releases.