https://github.com/loadtest4j/loadtest4j-jmeter
Apache JMeter driver for loadtest4j.
https://github.com/loadtest4j/loadtest4j-jmeter
api http load-testing testing
Last synced: 22 days ago
JSON representation
Apache JMeter driver for loadtest4j.
- Host: GitHub
- URL: https://github.com/loadtest4j/loadtest4j-jmeter
- Owner: loadtest4j
- License: mit
- Created: 2018-08-21T10:44:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-10T19:40:27.000Z (over 3 years ago)
- Last Synced: 2025-07-10T11:24:55.570Z (7 months ago)
- Topics: api, http, load-testing, testing
- Language: Java
- Homepage:
- Size: 58.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# loadtest4j-jmeter
[](https://travis-ci.com/loadtest4j/loadtest4j-jmeter)
[](https://codecov.io/gh/loadtest4j/loadtest4j-jmeter)
[](https://repo1.maven.org/maven2/org/loadtest4j/drivers/loadtest4j-jmeter/)
Apache JMeter driver for [loadtest4j](https://www.loadtest4j.org).
## Usage
With a new or existing Maven project open in your favorite editor...
### 1. Add the library
Add the library to your Maven project POM.
```xml
org.loadtest4j.drivers
loadtest4j-jmeter
test
```
### 2. Create the load tester
Use **either** the Factory **or** the Builder.
#### Factory
```java
LoadTester loadTester = LoadTesterFactory.getLoadTester();
```
```properties
# src/test/resources/loadtest4j.properties
loadtest4j.driver.domain = example.com
loadtest4j.driver.numThreads = 1
loadtest4j.driver.port = 443
loadtest4j.driver.protocol = https
loadtest4j.driver.rampUp = 5
```
#### Builder
```java
LoadTester loadTester = JMeterBuilder.withUrl("https", "example.com", 443)
.withNumThreads(1)
.withRampUp(5)
.build();
```
### 3. Write load tests
Write load tests with your favorite language, test framework, and assertions. See the [loadtest4j documentation](https://www.loadtest4j.org) for further instructions.
```java
public class PetStoreLT {
private static final LoadTester loadTester = /* see step 2 */ ;
@Test
public void shouldFindPets() {
List requests = List.of(Request.get("/pet/findByStatus")
.withHeader("Accept", "application/json")
.withQueryParam("status", "available"));
Result result = loadTester.run(requests);
assertThat(result.getResponseTime().getPercentile(90))
.isLessThanOrEqualTo(Duration.ofMillis(500));
}
}
```
## Generate HTML reports
The driver instructs JMeter to write its JTL report file to `./results/loadtest4j-[timestamp]/result.jtl`.
A standalone copy of JMeter can generate an HTML report from this file with the following command:
```bash
jmeter -g /path/to/result.jtl -o /path/to/html
```
You can also post-process the JTL file with any other compatible tool of your choice.