jmeter-as-code
jmeter-as-code copied to clipboard
Jmeter as code is the easy way to write jmeter test as code.
Write Jmeter tests as code.
An API that give access to full Jmeter feature as code, All designed object in GUI can be written as code.
Where to start
If you are new with Jmeter as code, try examples project and see documentation website.
A basic script example:
TestPlanWrapper testPlan = TestPlanWrapper.builder()
.addThread(ThreadGroupWrapper.builder()
.addSampler(
HTTPSamplerProxyWrapper.builder()
.withName("Home")
.withDomain("https://github.com")
.withProtocol("https")
.withPath("/anasoid")
.build())
.build())
.build();
ApplicationTest applicationTest = new ApplicationTest(testPlanWrapper);
applicationTest.run();
//OR
applicationTest.toJmx(new File("mytest.jmx"));
A basic script example using template:
TestPlanWrapper testPlan = TestPlanWrapper.builder()
.addThread(ThreadGroupWrapper.builder()
.addSampler(new HomePage())
.build())
.build();
ApplicationTest applicationTest = new ApplicationTest(testPlanWrapper);
applicationTest.run();
//OR
applicationTest.toJmx(new File("mytest.jmx"));
class HomePage extends
AbstractJmcTemplate<HTTPSamplerProxyWrapper, HTTPSamplerProxyWrapperBuilder<?, ?>> {
@Override
protected void prepareBuilder(HTTPSamplerProxyWrapperBuilder<?, ?> builder) {
super.prepareBuilder(builder);
builder.withName("Home")
.withDomain("https://github.com")
.withProtocol("https")
.withPath("/anasoid");
}
@Override
protected JmcWrapperBuilder<?> init() {
return HTTPSamplerProxyWrapper.builder();
}
}