Need example showing assertions that fail a simulation

Are there any full examples of how to use the Assertions functionality? I’m trying to get a simulation to appear to be failed so that maven will fail as well, but get compiler errors when using the below (or when I move assertThat to other lines). Thanks

basic.scala

package basic

import com.excilys.ebi.gatling.core.Predef._

import com.excilys.ebi.gatling.http.Predef._

import com.excilys.ebi.gatling.jdbc.Predef._

import com.excilys.ebi.gatling.http.Headers.Names._

import akka.util.duration._

import bootstrap._

import java.net.URLEncoder

class basic extends Simulation {

val httpConf = httpConfig

.baseURL(“http://www.google.com”)

.disableFollowRedirect

.disableWarmUp

.requestInfoExtractor( (request: Request) => { ListString } )

.responseInfoExtractor( (response: Response) => { ListString } )

val scn = scenario(“Scenario name”)

.exec(

http(“Robots”)

.get(“/robots.txt”)

.check(status.is(400))

)

setUp(scn.users(1).protocolConfig(httpConf))

assertThat(

global.failedRequests.percent.is(0)

)

}

Console Output

You’re using the assertions correctly but,
in order to use the Assertions API, you need to import assertions._ in your simulation.

Simply add :

import assertions._

after the others imports and it should work!

There is currently no assertions in our simulation examples, I’ll fix that shortly.

@Pierre: Can you also mention this in the migration guide, please?

Worked like a charm. Thanks!

It would be great to have it on the wiki page as well https://github.com/excilys/gatling/wiki/Assertions

Done

Wow, that’s fast. :slight_smile: Thanks!