Message is not printing on the console in jmeter using JSR223 and groovy

Pratik picture Pratik · Nov 6, 2013 · Viewed 26k times · Source

println() inside static void main method is not printing anything anywhere, whereas only println() prints in terminal. Here is my code:

class CalcMain {
static void main(def args) throws Exception {
    ScriptEngineManager factory = new ScriptEngineManager();
    ScriptEngine engine = factory.getEngineByName("groovy");

    println("testing");
  }
}

And when I ran it shows pass (Green Triangle in Jmeter) but doesnt print anything on terminal

Whereas a simple program such as

println("testing");

prints on terminal.

Could some one please let me know where I am doing wrong?

Thanks

Answer

djangofan picture djangofan · Jan 26, 2015

Don't use System.out.println in a Groovy or Beanshell step in jmeter. Instead , do this:

1. Enable the stdout console in Jmeter so that you can see the output.
2. Use  log.info("Message:" + vars.get("variableName"));  instead.