Search code examples
arraysjmeterbeanshellpost-processing

Jmeter: How to create an array in bean shell post processor and make it available in other thread groups?


Does anyone knows how to create an array in bean shell post processor and make it available in other thread groups?

I've been searching for a while and i'm not managing to solve this.

Thanks


Solution

  • Following some advice, here's how i did it:

    The HTTP request has a Regular Expressions Extractor to extract the XPTO variable from the request. Then, a BeanShell PostProcessor saves data to a CSV file:

    String xpto_str = vars.get("XPTO");
    log.info("Variable is: " + xpto_str);
    
    f = new FileOutputStream("/tmp/xptos.csv", true);
    p = new PrintStream(f); 
    this.interpreter.setOut(p); 
    print(xpto_str + ",");
    f.close();
    

    Then, in second thread group, i added a CSV Data Set Config, in which i read the variable from the file. This is really easy, just read the guide (http://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config).

    Thanks