1

I try to implement this : https://www.testautomationguru.com/jmeter-how-to-create-a-data-keyword-driven-framework-for-performance-testing/

I have a .csv file with the test case name in the first column. So I want to run a specfic test case according to the value in the .csv.

Test Plan
|--- Test Fragment
    |--- Switch Controller
         |--- Transaction Controller (TestCase1)
              |--- JSR223 Sample (TestCase1 script)   
         |--- Transaction Controller (TestCase2)
              |--- JSR223 Sample (TestCase2 script)   
         |--- Transaction Controller (TestCase3)
              |--- JSR223 Sample (TestCase3 script)
|--- Thread Group
     |--- CSV Data Set Config
     |--- Debug Sampler
     |--- ForEach Controller
          |--- Module Controller
     |--- View Result Tree

However if I put some code in JSR223 into Transaction Controller, like log.info("TEST !") nothing is display into the console.

Is there a solution to execute code write into JSR223 and display it into the console?

Moreover, in the View Result Tree I found this information: testcasename=TestCase1. So it seems to work but no log...

Thanks a lot.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Royce
  • 1,557
  • 5
  • 19
  • 44

2 Answers2

0

Simpy use OUT instead of log:

OUT.println("Hello Console");

OUT - System.out - e.g. OUT.println("message")

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Thank you for your answer. But even if I use `OUT.println("TEST")` nothing is display into the log. Maybe because the sampler is not in a `Thread Group` ? – Royce Oct 29 '19 at 14:08
  • 1
    @Royce `OUT` will display only in console, if you want also in log check @DmitriT answer – Ori Marko Oct 29 '19 at 14:09
  • @Royce if you want to just log keyword with JSR223, you can use ${__logn("write here your log")} see https://jmeter.apache.org/usermanual/functions.html#__logn – Ori Marko Oct 31 '19 at 10:49
0

Given you use log shorthand you will be able to see your TEST ! message only in jmeter.log file

enter image description here

If you want to see the message in STDOUT you should use println instead like:

println("TEST !")

If you want to continue using log shorthand and to see the messages both in jmeter.log file and STDOUT - you will need to amend JMeter logging configuration like:

  • in log4j2.xml file (lives in "bin" folder of your JMeter installation)
  • Under <Appenders> tag add the following block:

    <Console name="STDOUT" target="SYSTEM_OUT">
        <PatternLayout>
            <pattern>%d %p %c{1.}: %m%n</pattern>
        </PatternLayout>
    </Console>
    
  • Under <Root> tag add the following line:

    <AppenderRef ref="STDOUT"/>
    

enter image description here

Once you restart JMeter you should start seeing the same information as in the jmeter.log file in the STDOUT including your custom messages

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thank you for your answer. Unfortunately even with your modifications, nothing is display. Please confirm to me that I can use JSR223 Sampler outside of a `Thread Group` ? – Royce Oct 29 '19 at 14:17
  • If nothing is displayed then the Sampler is not executed. You cannot use it outside of the Thread Group – Dmitri T Oct 29 '19 at 14:29
  • So, if I follow this tutorial https://www.testautomationguru.com/jmeter-how-to-create-a-data-keyword-driven-framework-for-performance-testing/ how I'm supposed to write some code to define the keyword without a JSR223? thank you for your help. – Royce Oct 29 '19 at 14:33