Hi,
I'm unable to make assertion in exec block of code (Scala test) that fails the test if it's not passed.
My Gatling version I'm using is '3.7.3'
I'm doing request to http separately like:
val request = exec {
http("GET SOMETHING")
.get(<some endpoint>)
.header(<some header>)
.check(status.exists, status.saveAs("get.statusCode"))
}
And then I'm using it in definition of function like:
def someFunction = {
exec(
request.during(<some time>) {
exec(
session => {
allRequests += 1
if (session("get.statusCode").as[Int] == 200) {
successes += 1
}
session
}
)
})
I'd like to add some assertion in this someFunction to check, if percentage of successful requests (statusCode == 200) is not less than 10.
I've tried adding something like:
assert((successes*100)/allRequests >= 10))
But it does not fail the test scenario, when it's below that 10%.
I've tried using exitHereIfFailed or any of those types from Gatling documentation (but with no luck).
Moreover, I also added .assertions(forAll.failedRequests.count.is(0)) in setUp section. This also did not work (test is still ending with Build Successful).
I'm aware, there is also possibility to use an assertion for global requests (assertions(global.successfulRequests.percent.gt(10))), but I need my custom one.
Also I do not want to use any check, because counters (allRequests and successes) must be in request.during(<some time>) block.
Is there any option to use my custom counters and check percentage of successful request as in my example?
Hi,
I'm unable to make assertion in exec block of code (Scala test) that fails the test if it's not passed.
My Gatling version I'm using is '3.7.3'
I'm doing request to http separately like:
And then I'm using it in definition of function like:
I'd like to add some assertion in this
someFunctionto check, if percentage of successful requests (statusCode == 200) is not less than 10.I've tried adding something like:
But it does not fail the test scenario, when it's below that 10%.
I've tried using
exitHereIfFailedor any of those types from Gatling documentation (but with no luck).Moreover, I also added
.assertions(forAll.failedRequests.count.is(0))in setUp section. This also did not work (test is still ending withBuild Successful).I'm aware, there is also possibility to use an assertion for global requests (
assertions(global.successfulRequests.percent.gt(10))), but I need my custom one.Also I do not want to use any
check, because counters (allRequests and successes) must be inrequest.during(<some time>)block.Is there any option to use my custom counters and check percentage of successful request as in my example?