Introduction to Listeners

Introduction to Listeners

Introduction to listeners- A listener is a component that shows the results of the samples. The results can be shown in a tree, tables, graphs, or simply written to a log file. To view the contents of a response from any given sampler, add either of the Listeners “View Results Tree” or “View Results in the table” to a test plan. To view the response time graphically, add graph results, spline results or distribution graph. The listener’s section of the components page has full descriptions of all the listeners.

The “Configure” button can be used to specify which fields to write to the file, and whether to write it as CSV or XML. CSV files are much smaller than XML files, so use CSV if you are generating lots of samples.

The file name can be specified using either a relative or an absolute pathname. Relative paths are resolved relative to the current working directory (which defaults to the bin/ directory). Versions of JMeter after 2.4 also support paths relative to the directory containing the current test plan (JMX file). If the pathname begins with “~/” (or whatever is in the jmeter.save.save service.base_prefix JMeter property), then the path is assumed to be relative to the JMX file location.

If you only wish to record certain samples, add the Listener as a child of the sampler. Or you can use a Simple Controller to group a set of samplers, and add the Listener to that. The same filename can be used by multiple samplers – but make sure they all use the same configuration. 

Default Configuration- Introduction to Listeners

Introduction to Listeners- The default items to be saved can be defined in the jmeter.properties (or user.properties) file. The properties are used as the initial settings for the Listener Config pop-up and are also used for the log file specified by the -l command-line flag (commonly used for non-GUI test runs).

To change the default format, find the following line in jmeter.properties:

jmeter.save.saveservice.output_format=

The information to be saved is configurable. For maximum information, choose “xml” as the format and specify “Functional Test Mode” on the Test Plan element. If this box is not checked, the default saved data includes a time stamp (the number of milliseconds since midnight, January

1, 1970 UTC), the data type, the thread name, the label, the response time, message, and code, and a success indicator. If checked, all information, including the full response data will be logged.

The following example indicates how to set properties to get a vertical bar (“|”) delimited format that will output results like:.

The corresponding jmeter.properties that need to be set are shown below. One oddity in this example is that the output_format is set to csv, which typically indicates comma-separated values.

However, the default_delimiter was set to be a vertical bar instead of a comma, so the csv tag is a misnomer in this case. (Think of CSV as meaning character separated values)

The full set of properties that affect result file output is shown below.

#—————————————————————————

# Results file configuration

#—————————————————————————

# This section helps determine how result data will be saved.

# The commented out values are the defaults.

# legitimate values: xml, csv, db.  Only xml and csv are currently supported.

#jmeter.save.saveservice.output_format=csv

# true when field should be saved; false otherwise

# assertion_results_failure_message only affects CSV output

#jmeter.save.saveservice.assertion_results_failure_message=false

#

#jmeter.save.saveservice.data_type=true

#jmeter.save.saveservice.label=true

#jmeter.save.saveservice.response_code=true

# response_data is not currently supported for CSV output

#jmeter.save.saveservice.response_data=false

# Save ResponseData for failed samples

#jmeter.save.saveservice.response_data.on_error=false

#jmeter.save.saveservice.response_message=true

#jmeter.save.saveservice.successful=true

#jmeter.save.saveservice.thread_name=true

#jmeter.save.saveservice.time=true

#jmeter.save.saveservice.subresults=true

#jmeter.save.saveservice.assertions=true

#jmeter.save.saveservice.latency=true

#jmeter.save.saveservice.samplerData=false

#jmeter.save.saveservice.responseHeaders=false

#jmeter.save.saveservice.requestHeaders=false

#jmeter.save.saveservice.encoding=false

#jmeter.save.saveservice.bytes=true

#jmeter.save.saveservice.url=false

#jmeter.save.saveservice.filename=false

#jmeter.save.saveservice.hostname=false

#jmeter.save.saveservice.thread_counts=false

#jmeter.save.saveservice.sample_count=false

#jmeter.save.saveservice.idle_time=false

# Timestamp format

# legitimate values: none, ms, or a format suitable for SimpleDateFormat

#jmeter.save.saveservice.timestamp_format=ms

#jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS

# Put the start time stamp in logs instead of the end

sampleresult.timestamp.start=true

# Whether to use System.nanoTime() – otherwise only use System.currentTimeMillis()

#sampleresult.useNanoTime=true

# Use a background thread to calculate the nanoTime offset

# Set this to <= 0 to disable the background thread

#sampleresult.nanoThreadSleep=5000

# legitimate values: none, first, all

#jmeter.save.saveservice.assertion_results=none

# For use with Comma-separated value (CSV) files or other formats

# where the fields’ values are separated by specified delimiters.

# Default:

#jmeter.save.saveservice.default_delimiter=,

# For TAB, since JMeter 2.3 one can use:

#jmeter.save.saveservice.default_delimiter=\t

#jmeter.save.saveservice.print_field_names=false

# Optional list of JMeter variable names whose values are to be saved in the result data files.

# Use commas to separate the names. For example:

#sample_variables=SESSION_ID,REFERENCE

# N.B. The current implementation saves the values in XML as attributes,

# so the names must be valid XML names.

# Versions of JMeter after 2.3.2 send the variable to all servers

# to ensure that the correct data is available at the client.

# Optional xml processing instruction for line 2 of the file:

#jmeter.save.saveservice.xml_pi=<?xml-stylesheet type=”text/xsl” href=”sample.xsl”?>

# Prefix used to identify filenames that are relative to the current base

#jmeter.save.saveservice.base_prefix=~/

The date format to be used for the timestamp_format is described in SimpleDateFormat. The timestamp format is used for both writing and reading files. If the format is set to “ms”, and the column does not parse as a long integer, JMeter (2.9+) will try the following formats:

  • yyyy/MM/dd HH:mm:ss.SSS
  • yyyy/MM/dd HH:mm:ss
  • yyyy-MM-dd HH:mm:ss.SSS
  • yyyy-MM-dd HH:mm:ss
  • MM/dd/yy HH:mm:ss (this is for compatibility with previous versions; it is not recommended as a format)

Matching is now also strict (non-lenient). JMeter 2.8 and earlier used lenient mode which could result in timestamps with incorrect dates (times were usually correct).

Test Your Software Testing Skills By Taking Our JMeter Practice Tests On This Link

Become Vskills Certified JMeter Tester. Gain knowledge on the module “Introduction to Listeners”. Try the free practice test!

Apply For JMeter Certification

Go back to Tutorial

Share this post
[social_warfare]
Adding Web Service Requests
REMOTE TESTING

Get industry recognized certification – Contact us

keyboard_arrow_up