Created
December 5, 2023 10:58
-
-
Save jagedn/4084853c791c679d08456aced0931d9f to your computer and use it in GitHub Desktop.
a simple Groovy Scritp with JMeterDSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires groovy 3.0.11 | |
// sdk install groovy 3.0.11 | |
// sdk use groovy 3.0.11 | |
@GrabConfig(systemClassLoader=true) | |
@Grab("us.abstracta.jmeter:jmeter-java-dsl:1.23.3") | |
import static us.abstracta.jmeter.javadsl.JmeterDsl.* | |
import org.apache.http.entity.ContentType | |
user = args.length > 0 ? args[0] : 'YYYYYYYY' | |
pwd = args.length > 1 ? args[1] : 'XXXXXXXXXX' | |
iterations = args.length > 2 ? args[2] as int : 1 | |
users = args.length > 3 ? args[3] as int : 1 | |
baseUrl = args.length > 4 ? args[4] :"http://localhost:8080" | |
login = "Login.html" | |
stats = testPlan( | |
threadGroup (users, iterations, | |
httpSampler("$baseUrl"), | |
httpSampler("$baseUrl/$login") | |
.post("username=$user&password=$pwd", ContentType.APPLICATION_FORM_URLENCODED), | |
// a list of pages to check after login | |
httpSampler("$baseUrl/ListFilterDocumentsPending.html"), | |
httpSampler("$baseUrl/ListDocumentsRecentActivity.html"), | |
httpSampler("$baseUrl/ListFilterDocumentsRejected.html") | |
), | |
htmlReporter("reports/users-${user}-iterations-${iterations}") | |
).run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment