Creating first test case using Jmeter?

Scenario:- How to create a basic level test case(its called test plan) in jmeter?

Most of us things that ppl r born smart, but truth is 99% of the smartest ppl n this world are driven by commitment to learn, learn and learn more.Learn more and share more 🙂 Fb,G+,Twitter

1.Test plan :- Container for running the tests. Its the starting point, by default jmeter opens up with test plan.

2.Users(called as Thread Group in JMeter) :- How many users should be involved in sending the request to the server, how often, and ramp up time.
Why this ? it mimics the interaction of real users with the application at given time.

3.Task( what type of request that needs to be send to server, called as Samplers):-For example if we want to access the we are sending http request thus we need a particular type of sampler called http request sampler. If we are sending request to database we make use of jdbc sampler.

Note:- JMeter sends request to server based on the order they appear in the tree.

4.Assertions:– Verify the response send by server, comparing the actual value with expected value.

5.Report(called as Listeners in JMeter):- Request is send to server how to report the results for the response, we use Listeners for this.

Solution:- Lets create a pipeline for the above steps, 

ThreadGroup (We created users) > Samplers (users send request to server) > Assertions (Verify the response for the request) > Listeners (Report the response results as graphs, table and so on).

Step1:Launch jmeter 
Step2:-Add thread group 
Note:- We have renamed the test plan in our example below.

Right click Test Plan > Add > Thread(Users) > Thread Group
Rename Thread group to something logical.
Change the thread properties like number of users.

Thread group in jmeter

Step3:-Add sampler 

Right click Thread Group > Add > Sampler > HTTP Request 
Rename it something logical
Define user defined variables for a test plan (FirstTestCaseJMeter) .

  • Open test plan
  • click on Add
  • Enter name and value
Why this as it add to maintainability of application url at one place.

user defined variables in jmeter

Add APP variable into the Sampler “Server Name” like ${APP}(this is how we use variable value in jmeter ${variableName}
Select the method as “GET”

http request jmeter

Note:-Incase we need to pass any parameters or body elements we can do it here.

Step4:-Assertions (say to check 200 status code)
Right click Thread Group > Add > Assertions > Response Assertion
Select ReponseCode  and Equals, put value as 200 

response assertion jmeter

Step5:-Listeners (Report the run results)
Right click Thread Group > Add > Listener > View Result Tree

Step6:-Run the test plan
Before running we need to save the .jmx file
Ways to run :-

  • Run > Start
  • Ctrl + r
  • Green play button on the menu bar
jmeter run options

Step7:-Check the run results
Select View Result Tree
Its green, means our assertion is successful and we got the response back 🙂

run results jmeter

So we successfully created the basic test plan in jmeter. To explore more change the listener type, add more users and add different type of assertions.

Learn more and share more.

Leave a Reply

Your email address will not be published. Required fields are marked *