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

后端 未结 5 1545
忘掉有多难
忘掉有多难 2021-01-04 00:19

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

class Ca         


        
5条回答
  •  情歌与酒
    2021-01-04 00:57

    You have not provided all code, just your part produces errors as imports are also needed. Definition of class does not run by its own, you need as instance and then run in explicitly, then it prints (both with and w/out System.out. prefix) to terminal:

    import javax.script.ScriptEngine;
    import javax.script.ScriptEngineManager;
    
    class CalcMain {
    static void main(def args) throws Exception {
        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("groovy");
    
        println ("testing1");
        System.out.println ("testing2");
      }
    }
    
    CalcMain test1 = new CalcMain();
    test1.main();
    println ("testing3");
    

    Output:

    testing1
    testing2
    testing3
    

提交回复
热议问题