xUnit equivalents for performance testing



  • 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.



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


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2