-1

Good evening everyone. I'm wondering if there are libraries in any programming languages that can generate load/performance tests.

I'm picturing a test script that would fit in next to the integration and automated tests that would essentially generate a jmeter .jmx file and run the associated tests (just as an example, I'm open to other performance testers). Ideally, it would be ran in the same server the rest of the test suite is running in (so a dev team can get live updates on the performance of their applications after each commit along with the rest of the test statistics).

Does a thing like this exist? It seems like .jmx files are just basic XML without any real uniqueness, it's hard to imagine there isn't a tool for this already but I cannot find anything.

I hope I communicated my question good enough.

  • "It seems like .jmx files are just basic XML without any real uniqueness" what do you mean by uniqueness? I didn't understood your problem - could you state what limitation JMeter has that you want to overcome with a different tool? – João Farias Aug 14 at 7:21
  • the limitation that I have to use the GUI to make tests. I'm asking if I can create performance tests the same way I can create unit tests, with a few lines of code, and have the tests run after every commit – ewhiting Aug 14 at 11:04
0

If you're going to benchmark pieces of software (i.e. functions or classes) you could look a microbenchmark library for the programming language of your choice. For example for Java there is JMH project

With regards to creating JMeter tests / running JMeter programatically it should be fairly easy as well as JMeter is free and open source and has quite well documented API giving full control of JMeter engine(s). Check out Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information and some code snippets. The minimal working class which runs an existing .jmx script from Java would be:

import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.reporters.ResultCollector;
import org.apache.jmeter.reporters.Summariser;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;

import java.io.File;

public class ExistingTest {

    public static void main(String[] args) throws Exception {
        StandardJMeterEngine jmeter = new StandardJMeterEngine();

        JMeterUtils.loadJMeterProperties("/path/to/your/jmeter/bin/jmeter.properties");
        JMeterUtils.setJMeterHome("/path/to/your/jmeter");
        JMeterUtils.initLocale();

        SaveService.loadProperties();

        HashTree testPlanTree = SaveService.loadTree(new File("/path/to/your/jmeter/extras/Test.jmx"));

        Summariser summer = null;
        String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
        if (summariserName.length() > 0) {
            summer = new Summariser(summariserName);
        }

        String resultFile = "/path/to/test/result.jtl";
        ResultCollector logger = new ResultCollector(summer);
        logger.setFilename(resultFile);
        testPlanTree.add(testPlanTree.getArray()[0], logger);

        jmeter.configure(testPlanTree);
        jmeter.run();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.