JMETER

TEST PLAN ELEMENT ORDER OF EXECUTION

TEST PLAN ELEMENT ORDER OF EXECUTION

Test plan elements are always executed according to the below order.

1. Configuration nodes

2. Pre processors

3. Timers

4. Sampler

5. Post processors (only executed if there are results available)

6. Assertions (only executed if there are results available)

7. Listeners (only executed if there are results available

JMETER WEB TEST PLAN:

We will design a web test plan to test a webpage. 

We will create five users that send requests to two pages on the JMeter Web site. Also, we will tell the users to run their tests twice. So, the total number of requests is (5 users) x (2 requests) x (repeat 2 times) = 20 HTTP requests. We will be using the following elements to create the test plan: Thread group, HTTP request, HTTP request defaults and results.

  1. Rename test plan name to “WebTestplanDemo”.


  1. Add thread group (users) -

  Context Menu over Test Plan → Add → Thread →ThreadGroup


Configure the thread group created in step 2 above. We will edit the default values at the section to the right of thread group control panel in JMeter window.

Name – Add a name like “Users”

number of Threads =Set number of threads to “5”. This will increase the number of users to 5.

Ramp-Up Period =Default it to 1 second. Ramp up period tells the user the delay between each user. Here JMeter will finish starting all users by the end of defined ramp up period which is 1 second. When ramp up period is set to 0, JMeter will start all users simultaneously.

Loop count – This property is used to define the number of times the test should be repeated.

Action to be taken after sampler error – we can also select the action upon error depending upon test case.

We can also configure if we wish to use the same user for each iteration or different user.

Add HTTP Request sampler-
Context Menu over Test group (users) → Add → Sampler → HTTP request.
An empty HTTP request sampler will be created under the thread group with name users.


  1. Configure the sampler create in step 4 above.
  1. Name – enter a name suitable to the request for e.g. – homepage
  2. Protocol- default value of protocol is http, as such we will leave it blank.
  3. Server name /Ip – Set the server’s name to the name of the server we want to test: www.wikipedia.org (without the http or https protocol) in this case.
  4. You should modify the connection values for port, protocol, method to execute in the server, etc. if needed.
  5. HTTPS request type – GET
  6. Path: set to / which implies that we want the root page of the server.


  1. Add Listener: Listeners help to view results of the sampler node later.

Context Menu over Test group (users) → Add → Listener → View results Tree option.

  1. Save and run the test plan.

File →Save (or click "Control + s")

Run →Start (or click play as explained before)

Apache JMeter asks us to save the test plan in a disk file before actually starting the test. This is important if you want to run the test plan multiple times. You can opt for running it without saving too by selecting “NO”


8) View results:


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 behaviour). We can play around with the results and check all the
returned data.

Details of the above result are −

  1. Green colour against the name Home Page indicates success.
  2. JMeter has stored all the headers and the responses sent by the web server and ready to show us the result in many ways.
  3. The first tab is Sampler Results. It displays JMeter data as well as data returned by the web server.
  4. The second tab is Request, which displays all the data sent to the web server as part of the request.
  5. The last tab is Response data. In this tab, the listener displays the data received from server in text format.

9. Add timer – 

Context Menu over Test group (users) → Add → Timer → Constant timer

Update thread delay (millisecond) to 500. This will ensure that every request will wait 500 millisecond after the last one is finished


10) Add assertion:

Context Menu over Test group (users) → Add → Assertions →Duration assertion

we configure it to assert false if the response takes longer than 100 milliseconds,


Database test plan

We will design a data base test plan will help us test a database server. We will create 50 users which will send 2 SQL requests to the database server. Additionally, we will tell the users to run their tests 100 times. So, the total number of requests will be (50 users) x (2 requests) x (repeat 100 times) = 10'000 JDBC requests. We will use the following elements to construct the database plan: Thread Group, JDBC Request, Summary Report.

 

  1. Add users/Thread group: Context Menu over Test Plan → Add → Thread →Thread Group
  2. Configure the thread group created in step 1 above. We will edit the default values at the section to the right of thread group control panel in JMeter window.
     
  3. Name – Add a name like “JDBC Users”
  4. number of Threads =set this field value to “50”. This will increase the number of users to 50.
  5. II. Ramp-Up Period =Set ramp up period to 10 seconds. Ramp up period tells the user the delay between each user. Here JMeter will finish starting all users by the end of defined ramp up period which is 10 seconds. So for 50 users having 10 second Ramp-Up Period, then the delay between starting users would be 200 milliseconds (10 seconds / 50 users = 0.2 second per user). When ramp up period is set to 0, JMeter will start all users simultaneously.

    III. Loop count –We will set it to “100” indicating that the test should run 100 times.


 

  1. Add JDBC Requests sampler -

Context Menu over Test group (users) → Add → Config element → JDBC Connection Configuration.

Add the values corresponding to below fields related to the database which you will be using.

  1. Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used.
  2. Database URL
  3. JDBC Driver class
  4. Username: the username of database
  5. Password: password for the username


  1. Add JDBC Request sampler- Context Menu over Test group (users) → Add → Sampler → JDBC request.

 

5) Configure JDBC sampler - select this new element to view its Control Panel

  1. Change the Name to 'VM Running'.
  2. Enter the Pool Name: 'My Database' (same as in the configuration element)
  3. Enter the SQL Query String field.
  4. Enter the Parameter values field with 'Running' value.
  5. Enter the Parameter types with 'VARCHAR'.


  1. Add Listener;

Add Listener: Listeners help to view results of the sampler node later.

Context Menu over Test group (users) → Add → Listener → Summary Report

Save the test plan, and run the test with the menu Run → Start or Ctrl + R