Skip to content

anasoid/jmeter-as-code

Repository files navigation

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.

Build & Test Audit Coverage Lines of Code Security Rating Reliability Rating Maintainability Rating

Maven Central javadoc

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();
  }
}

            

  

About

Jmeter as code is the easy way to write jmeter test as code.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages