Simple Java API to run performance tests, using JMeter as engine, in a Git and programmers friendly way.
If you like this project, please give it a star ⭐! This helps the project be more visible, gain relevance, and encourage us to invest more effort in new features.
Here you can find the .Net DSL.
Please join discord server or create GitHub issues and discussions to be part of the community and clear out doubts, get the latest news, propose ideas, report issues, etc.
Usage
If you use maven, just include the following dependency:
<dependency>
<groupId>us.abstracta.jmeter</groupId>
<artifactId>jmeter-java-dsl</artifactId>
<version>1.21</version>
<scope>test</scope>
</dependency>
Here is a simple example test in JUnit 5+ with 2 threads/users iterating 10 times each to send HTTP POST requests with a JSON body to http://my.service
:
import static org.assertj.core.api.Assertions.assertThat;
import static us.abstracta.jmeter.javadsl.JmeterDsl.*;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import org.apache.http.entity.ContentType;
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")
.post("{\"name\": \"test\"}", ContentType.APPLICATION_JSON)
),
//this is just to log details of each request stats
jtlWriter("target/jtls")
).run();
assertThat(stats.overall().sampleTimePercentile99()).isLessThan(Duration.ofSeconds(5));
}
}
This example also uses AssertJ for assertions, but you can use whatever assertion library you choose.
More examples can be found in tests
You can use this project as a starting point.
Tip 1: Check the DSL recorder and jmx2dsl to ease test plan creation or migration from existing JMX files.
Tip 2: Since JMeter uses log4j2, if you want to control the logging level or output, you can use something similar to the tests included log4j2.xml.
Tip 3: When working with multiple samplers in a test plan, specify their names to easily check their respective statistics.
Check here for details on some interesting use cases, like running tests at scale in BlazeMeter or OctoPerf, saving and loading test plans from JMX, publishing test metrics to InfluxDB (and visualizing them from Grafana), and general usage guides.
Why?
Check more about the motivation and analysis of alternatives here
Support
Join our Discord server to engage with fellow JMeter DSL enthusiasts, ask questions, and share experiences. Visit GitHub Issues or GitHub Discussions for bug reports, feature requests and share ideas.
Abstracta, the main supporter for JMeter DSL development, offers enterprise-level support. Get faster response times, personalized customizations and consulting.
For detailed support information, visit our Support page.
Articles & Talks
- Developer’s friendly tools for continuous performance testing: Walk-through from Fiddler recording to JMeter DSL test plan by Belen Vignolo @ Abstracta. Russian translation by Ksenia Moseenkova.
- JMeterDSL: Bringing Performance Testing Closer to Developers: Intro to JMeter DSL and scaling execution in BlazeMeter by Yaina Machado.
- Performance testing tools trend: A quick review of different alternatives for performance testing in Java and associated trend by Roger Abelenda @ Abstracta.
- JMeter scripting: la pieza faltante: Spanish demo by Roger Abelenda and hosted by Blanca Moreno @ QA Minds.
- Getting Started with JMeter DSL: Intro to JMeter DSL and general thoughts by Roger Abelenda and hosted by NaveenKumar Namachivayam @ QA Insights. Here is the video version.
- Virtual Threads: JMeter meets Project Loom: Experimenting with Virtual Threads in JMeter using JMeter DSL as a prototyping tool by Roger Abelenda @ Abstracta. Here is the Spanish version
- JMeter Scripts Written in Java??: JMeter DSL demo and discussion at PerfBytes session by Roger Abelenda and hosted by Mark Tomlinson.
- JMeter: test as code solutions: JMeter DSL & Taurus review by Gérald Pereira @ OctoPerf.
- JMeter DSL, an Innovative Tool for Performance Testing: Short article on JMeter DSL motivation by Roger Abelenda @ Abstracta. Spanish version.
- JMeter DSL, the Story of Abstracta’s Latest Innovation in Software Testing: Post about JMeter DSL inception story by Natalie Rodgers & Roger Abelenda @ Abstracta. Spanish Version.
- Develop JMeter Scripts Using Java with Roger Abelenda: Short interview by Joe Colantonio from TestGuild to Roger Abelenda about JMeter DSL basics.
- PerfOps - faster and cheaper through a service approach: A nice analysis on implementing a performance experts service while using JMeter DSL as basics for creating a framework on top of it by Kirill Yurkov. (In Russian, but you can use Chrome Translation ;))
- pymeter announcement: Announcement of a python API, built on top JMeter DSL, which eases JMeter test plan creation and execution for python devs by Eldad Uzman.
- Evolve Your Selenium Scripts Into Performance Scripts: SeleniumConf 2023 talk showing generation of performance scripts from Selenium scripts, using JMeter DSL recorder. Here is demo repository.
- Developer-Friendly JMeter DSL for Authoring JMeter Scripts: Azure Load Testing article on integration between JMeter DSL and Azure Load Testing.
- JMeter DSL: Un giro emocionante en las pruebas de rendimiento: Short Spanish article that highlights some of the benefits and differentiators of using JMeter DSL and included recorder.
Ecosystem
- pymeter: python API based on JMeter DSL that allows python devs to create and run JMeter test plans.
Contributing & Requesting features
Currently, the project covers the most used features required when implementing JMeter performance tests, but not everything the JMeter supports/provides.
We invest in the development of DSL according to the community's (your) interest, which we evaluate by reviewing GitHub stars' evolution, feature requests, and contributions.
To keep improving the DSL we need you to please create an issue for any particular feature or need that you have.
We also really appreciate pull requests. Check the CONTRIBUTING guide for an explanation of the main library components and how you can extend the library.