5 minutes read

What are assertions ?

In case you are not familiar with the term, an assertion “is a test / a condition that must be tested to confirm conformance to a requirement”. Basically a test assertion is – a condition that compares the expected value with the actual value for a specified use case.

 

Why should I use assertions ?

Before we deliver a product, we need to run many test assertions to make sure the product meets the customer’s expectations. Also, you can check our intro blog post regarding how to run a load test with Apache JMeter.

 

 

Should we use assertions in the JMeter tests ?

Usually assertions are not used when we create the scripts for load or stress testing an application. Most of the tester that run
these kind of tests base their results only on the response status codes that the application under test returns. This might be a problem and might make the final results not accurate.

What are the cases in which not using an assertions may affect your final results ?

Not all the time a successfull response from the server (200 OK) means that the application responded as expected.
You may ask yourself and the a few cases are mentioned below:

  1. the application redirects to a maintaince page
  2. the application responds a 200 OK but sends an error message in the body of the response indicating a error message
  3. the application redirects to an error page and sends back a 200 OK with and error message indicating why the error returns

To avoid these kind of errors to affect your performance report is a very good idea to use assertions:

  • in GET/POST/PUT/PATCH methods
  • in API performance testing
  • in functional testing

Be aware that if your are creating a long running test or a test with a lot of requests is good not to use a lot of assertions as
they tend to consume quite a bit of memory which could make your JMeter tool crash and means starting the test again.

What type of assertions does JMeter support ?

There are several types of assertions that you can use in your test scripts.
The most used ones are:


You can also use LoadFocus to load test your websites, APIs or any web-app with thousands of users from AWS cloud locations.

 

How fast is your website? Free Website Speed Test