Before going through this please check out earlier blog on Jmeter
As we have already learnt In order to run Jmeter on an weblink.
First we need to have
1. Thread group (Users)
a. Number of thread (users)----users going to hit the link
b. Ramp-up period-- Time taken by the user to hit the link
as shown above users are 10 time taken by them is 20 so each user will take 2 seconds to hit the link
c. If infinite (loop will continue until manually stopped)
d. uncheck the infinite and enter the no of times you want to run the loop if you choose 2 as shown
below then it means link will be hit by 10 users in 20 seconds then again it will be hit by 10 users in 20 seconds
By right clicking on thread group you can also add frequently used 2 listener as shown below a. view results tree
b.view results in table
You should also add sampler to the thread group HTTP Request. as shown below
Once HTTP request is added mention the server Name and Path
for example you have the weblink. https://reqres.in/api/users?page=2
server link is reqres.in (No need to provide https here)
You can run it by any way by clicking on run button or clicking on green arrow
Once run you can check the result
The loop has run exactly 2 time with 10 user in 1 loop mean 20 hits by user you can count that on Results
Tree view
Table view
You can also check No of samples (last line in screenshot) i.e. 20
No we can add the assertion,
Assertion
It is used to validate response in the request , its used to verify Expected result with the actual result
for the above result success code which is 200
If you have no idea what are response code below is the example
200 OK | Successful. |
201 Created | Created. |
202 | Accepted |
300 Multiple choices |
|
301 Moved permanently |
|
302 Found |
|
400 Bad Request | Bad input parameter. Error message should indicate which one and why. |
401 Unauthorized | The client passed in the invalid Auth token. Client should refresh the token and then try again. |
403 Forbidden | * Customer doesn’t exist. * Application not registered. * Application try to access to properties not belong to an App. * Application try to trash/purge root node. * Application try to update contentProperties. * Operation is blocked (for third-party apps). * Customer account over quota. |
404 Not Found | Resource not found. |
405 Method Not Allowed | The resource doesn't support the specified HTTP verb. |
409 Conflict | Conflict. |
411 Length Required | The Content-Length header was not specified. |
412 Precondition Failed | Precondition failed. |
429 Too Many Requests | Too many request for rate limiting. |
500 Internal Server Error | Servers are not working as expected. The request is probably valid but needs to be requested again later. |
502 Bad Gateway |
|
503 Service Unavailable | Service Unavailable. |
504 Gateway Timeout |
|
Go to the thread group add frequently used assertion- Response assertion
Once added you can can change field to test as. "Response Code"and Pattern matching rule as "Equals"
as we are checking expected result should be equal to actual result that is success
In order to achieve this click on "add" button and under "pattern to test" enter "200" response code
and click on "Run"
This time i made the loop count 1 so it will run for 10 users in 20 seconds
Check the result Tree view (verify that it has run for 10 users) -> sampler result you can verify the response code
Table view
Once we have verified actual and expected result lets take an example where expected is not equal to actual result
Let's fail the assertion by making the reponse code 500
Go to thread group check the settings and Now run it
Check the result in tree view you can see Assertion result-received- 200
comparison-500 It's failed
Check in Table view
To give a more user friendly view of assertion lets add "assertion result" as shown below
For deviation in actual to expected result(500 -200) result failed Assertion result will be Assertion result will be locked
When actual and expected are same (200-200) result passed assertion result will be
add Duration Assertion
which use to verify if any of the response took more time then the specified time
Now my current thread group is 10 user in 10 second and only 1 loop count
sample time taken by every hit can be fetched from Table view
we want to check is it is taking more time then 700ms
Go to duration assertion enter 700 ms hits taking time less then 700ms will be passed
Run and check in result hist taking more then 700ms should be failed Tree view
Table view
Assertion result
Failed one detailing will be present
Lets move on to another assertion. which is a Size assertion .
Size in bytes can be checked Lets enter the size in byte 2620 if its <= 2620 then it should pass else it will fail
Before running do not forget to remove duration assertion milliseconds column or it will give result for duration as well as size assertion
check the result in table formatfailed ones are those whose size is greater than 2620
Assertion result
Moving on to HTML Assertion it is going to check if the format of our response is valid HTML or not
Once run it will throw an error message(before moving on please remove condition in previous assertion added)
in HTML assertion we can provide threshold for the error and warning
It should not throw an error or fail as we have errors and warning within the threshold
assertion result you can check its passed successfully
If you wanted to save all error result in a file In HTML assertion -click on Errors only and browse select and save file namecheck the file it will have all errors and warnings
Comments
Post a Comment