Skip to content
  • ZipCode Api
  • Blog
  • About RedLine13
RedLine13
RedLine13
Primary Navigation Menu
Menu
  • Start Testing
  • Demo
  • Pricing
  • JMeter
  • Partners
  • Docs
    • Documentation Home
    • AWS Set Up for load testing
    • AWS Approval for Large Tests
    • PHP, NodeJS, Python Load Tests
    • Scalability
    • Jenkins Plugin Setup
    • Premium Features
    • Knowledge Base

What are my options for using Assertions in JMeter

By: RedLine13

Apache JMeter provides a variety of assertions which are helpful to apply a few checkpoints with each request. However the assertion must be carefully used because it consumes resources (memory or CPU). Below is a list of JMeter assertions:

  • Bean shell assertion: allow the user to write their bean shell script to perform assertion.
  • Compare assertion: used to compare sample results within its scope
  • Duration assertion: check the response time of the request, if the request takes longer time than is specified in milliseconds then request will be marked as fail.
  • HTML assertion: check the HTML syntax of the response data using JTidy
  • JSR223 assertion: allow user to write JSR223 script to check the status of the request
  • MD5Hex assertion: Use to check the MD5 hash of the response data
  • BSF assertion: allow user to write BSF script to check various aspects of the SampleResult
  • Response assertion: commonly used assertion which allows user to add pattern strings comparing against various fields of the response.
  • Size assertion: allow the user to put a checkpoint on the size of the response. Provides comparison operators like =, <, >, != etc.
  • SMIME assertion: use to evaluate the sample results from the Mail Reader Sampler
  • XML assertion: checks that the response data consists of a formally correct XML document.
  • XML Schema assertion: allow the user to validate a response against an XML Schema. The schema file is required.
  • XPath assertion: Tests a document for well-formedness, has the option of validating against a DTD, or putting the document through JTidy and testing for an XPath

For more documentation, refer to http://jmeter.apache.org/usermanual/component_reference.html#assertions

Example assertion to confirm response has value using RegEx

We can apply a regex assertion in a response to confirm the response has certain text/values available. For example, we get a response from weather API in below format depending upon the city parameter in api call. We wanted to put an assertion to confirm that response always have fields (marked bold) with different values depending upon each request and input parameters.

{“coord”:{“lon”:-0.13,”lat”:51.51},
“weather”:[{“id”:522,”main”:”Rain”,”description”:”heavy intensity shower rain”,”icon”:”09n”}],
“base”:”stations”,
“main”:{“temp”:279.31,”prestassure”:982,”humidity”:93,”temp_min”:278.15,”temp_max”:281.45},
“visibility”:10000,
“wind”:{“speed”:2.1,”deg”:150},
“clouds”:{“all”:24},
“dt”:1452480859,
“sys”:{“type”:1,”id”:5093,”message”:0.0225,”country”:”GB”,”sunrise”:1452499363,”sunset”:1452528850},
“id”:2643743,
“name”:”London”,
“cod”:200}
 

Screen Shot 2016-01-19 at 10.25.57 AM

Here is a copy of the JMeter test plan with example API calls and response assertions with regex.

https://www.redline13.com/share/testplan/23122

2016-01-19
Previous Post: Recording with JMeter Proxy
Next Post: JMeter HTTP Cache Manager

Recent Posts

  • Cost-Effective Cloud Load Testing
  • Guest Post: Load Testing with Locust and JMeter on RedLine13
  • Executing Gatling Tests with The SBT + Java RedLine13 Plugin
  • Selenium Load Testing: When and How
  • RedLine13 Basic vs Premium Subscription

Related

  • How to Run a Multi-Region Test – Available in Paid and Free Plans
  • Cost-Effective Cloud Load Testing
  • Guest Post: Load Testing with Locust and JMeter on RedLine13
  • Selenium Load Testing: When and How
  • Selecting Custom OpenJDK version for JMeter
  • Executing Gatling Tests with The SBT + Java RedLine13 Plugin
  • JMeter Alternatives: k6 and Gatling
  • RedLine13 Basic vs Premium Subscription
  • Speak the Lingo using Load Testing Terms
  • API Load Testing with cURL and RedLine13

© RedLine13, LLC | Privacy Policy | Contract
Contact Us: info@redline13.com

Designed using Responsive Brix. Powered by WordPress.