JMeter environment specific configuration

后端 未结 8 651
时光取名叫无心
时光取名叫无心 2021-02-04 13:05

I have several JMeter test plans which should be executed in different environments, say Dev, Test, UAT, Live. In each test plan I would like to have a simple way to specify whi

8条回答
  •  不思量自难忘°
    2021-02-04 13:38

    As the current solution I'm using JSR223 sampler with custom JavaScript code to set up variables from external properties-files. Something like that:

    var file = new java.io.File(args[0]);
    var props = new java.util.Properties();
    var is = new java.io.FileInputStream(file);
    props.load(is);
    is.close();
    for(var it = props.entrySet().iterator(); it.hasNext();)
    {
        var entry = it.next();
        vars.put(entry.getKey(), entry.getValue());
    }
    

    Now I just need to add this code as the very first sampler in a test plan and pass environment specific filepath as the sampler parameter args[0] it will load variables from the file and put them as JMeter variables.

提交回复
热议问题