0% found this document useful (0 votes)
5 views2 pages

Advanced JMeter User API Framework

The document outlines an advanced API automation framework using Apache JMeter and Groovy for automating REST APIs (POST, GET, PUT, PATCH, DELETE). It includes test data in CSV format, Groovy assertions for each API method, eligibility validation, correlation examples, and best practices for implementation. Additionally, it provides an execution command for running the tests.

Uploaded by

sivakumarrgs2025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Advanced JMeter User API Framework

The document outlines an advanced API automation framework using Apache JMeter and Groovy for automating REST APIs (POST, GET, PUT, PATCH, DELETE). It includes test data in CSV format, Groovy assertions for each API method, eligibility validation, correlation examples, and best practices for implementation. Additionally, it provides an execution command for running the tests.

Uploaded by

sivakumarrgs2025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JMeter + Groovy Advanced API Automation Framework

1. Objective

Automate REST APIs (POST, GET, PUT, PATCH, DELETE) using Apache JMeter with Groovy
scripting in a scalable and maintainable way.

2. Test Data (CSV)


userId,name,email,age,eligibility
1,John,john@[Link],25,eligible
2,Alice,alice@[Link],17,not_eligible
3,Bob,bob@[Link],35,eligible

3. POST - Create User

{
"id":"${userId}",
"name":"${name}",
"email":"${email}",
"age":"${age}"
}

Groovy Assertion

import [Link]
def res = new JsonSlurper().parseText([Link]())
assert [Link]() == "201"
assert [Link] == [Link]("userId")

4. GET - Fetch User

GET /users/${userId}

Groovy Assertion

import [Link]
def res = new JsonSlurper().parseText([Link]())
assert [Link] == [Link]("name")

5. PUT - Replace User

{
"name":"Updated_${name}",
"email":"updated_${email}",
"age":30
}

6. PATCH - Update User


{
"email":"patched_${email}"
}

7. DELETE - Remove User


DELETE /users/${userId}

8. Eligibility Validation

if ([Link]("eligibility") == "not_eligible") {
[Link]("expectedStatus", "400")
} else {
[Link]("expectedStatus", "200")
}

assert [Link]() == [Link]("expectedStatus")

9. Correlation Example

def json = new [Link]().parseText([Link]())


[Link]("userId", [Link])

10. Best Practices

- Use JSR223 with Groovy - Avoid hardcoded values - Use CSV for data-driven testing - Implement
correlation - Add response time assertions - Integrate with CI/CD tools like Jenkins

11. Execution Command

jmeter -n -t [Link] -l [Link] -e -o report

You might also like