Web (HTTP) test plan in jmeter

In this chapter we are going to see how to create a plan to test an specific web page via HTTP. For that purpose i will use the http://www.wikipedia.org site.
So enough theory, now we are going to see how to configure an HTTP request test plan.
  • Rename Test Plan to the name that you like
In this step is possible to configure the test plan in general terms affecting the behavior of Threads and you can add external libraries that should be used. We are not going to do that in this example.
main test plan
  • Add Thread Group
In this step you need to create a Thread group in charge of executing all the components of the test and configure its main properties: number of threads, ramp up period in seconds and number of iterations.
Context Menu over Test Plan -> Add -> Thread ->ThreadGroup
main http test plan
you can also specify the action you want to take in case of error (continue, stop, stop current Thread…)
  • Add Sampler HTTP Request
In this step we add the sampler with the information of the HTTP Request that we want to test:
Add Sampler->HTTP Request
We need to set different properties for this type of request:
Set the server name to the name of the server we want to test: www.wikipedia.org (without the http or https protocol) in this case. You should modify the connection values for port, protocol, method to execute in the server, etc. if needed, if our case this is not necessary. There are several parameters for configuring proxies, timeouts and different header information as well, but in our case, we leave everything with the default values
http config sampler
  • Add Results Listener
This is needed to be able to see the results afterwards; there are several possibilities as we saw before in this tutorial, for our HTTP Request test plan we are going to use a View Results Tree:
Add Listener -> View Results Tree
For our example, we do not change anything there and leave all the configuration properties with the default values.
http results empty
  • Save the test plan and Run it
File->Save (or click “Control + s”)
Run->Start (or click play as explained before)
  • Check results in the listener
http results fine
We can see that all the requests have been done as expected and all of them provide meaningful responses, so it seems that the web page that we are testing works fine (if this is the expected behavior). We can play around with the results and check all the returned data.
We have already configured a test plan that sends a bunch or requests to a given server and parses the responses. We are going to see now how to use other type of test components like Timers and Assertions.
  • Add a timer
In order to add a Timer we just right click on the test plan and add a timer:
Add Timer->Constant Timer
and we configure it with 500 miliseconds. Every request will wait 500 ms after the last one is finished.
timer
  • Add duration assertion
On the test plan, right click and add a duration assertion, we configure it to assert false if the response takes longer than 100 ms, and we configure it for the main sample only:
Add assertion->Duration assertion
duration assertion 100
If we re run the test plan (after saving) we will see that we have some issues with this assertion:
http results error assertion duration
Obvioulsy this happens because we configure the duration assertion only with 100 ms, if we change this figure to 2000 ms almost all requests will be served on time.
  • Add size assertion
Add assertion->Size Assertion
and we assure that the response has a size larger than 5000 bytes:
size assertion 5000
If we run the test we will see that the response is always larger than that, in case of an error response the size would be, probably, smaller and our assertion will fail.