I am trying to run a simple performance-test through Gatling. I use maven to run the process. In order to easely pick up when changes in the code breaks my gatling-tests I want the maven-build to fail. I have made sure to add <failOnError>true</failOnError>
in my pom.xml file.
My current script is something like this:
class MySim extends Simulation {
val httpProtocol = http.baseURL("http://localhost:8080")
val scn = scenario("Test")
.exec(http("request_1")
.get("""/helloworld""")
.check(status.is(200))
)
setUp(scn.inject(ramp(1 users) over (1 seconds))).protocols(httpProtocol)
}
I run the build using maven (with the gatling-maven-plugin) using mvn clean gatling:execute
which will allways succeed. (even when the server isn't running). I am looking for a way to make sure the maven builds fails when gatling-test fails (or has a too high fail-percentage).
So I figured out a solution: All I had to do was add assertions to the setUp, with the criteria I wanted. So the following code would fail the maven-build if the successrate was lover than 90%.
setUp(scn.inject( ... ))
.protocols(httpProtocol)
.assertions(
global.successfulRequests.percent.greaterThan(90)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With