Hi everyone,
I’m currently migrating a bunch of scenarii from Gatling 2.3.1 (Scala 2.12.3) to 3.4.2 (Scala 2.12.12).
I followed the migration guides (https://gatling.io/docs/current/migration_guides/), but still have compilation issues that I can’t figure out how to fix. This may be only due to my poor Scala or Gatling internals knowledge, but I can’t make it through.
Note that all this code was happily compiling and working with version 2.3.1 (for years :-)).
It may be that a prior code flaw of my own is now becoming out as a compilation error due to a stricter compilation setting / type checking / design, but I’m at loss to see why and how to fix it. :’-|
The construct having the issue is a function providing two different checks depending on the app version (small class SemanticVersion stripped from code below):
val pagename = if ( version >= SemanticVersion(“3.2.0”) ) css("#pageName") else regex("""“pageName”\s*:\s*"([^"]*)"""")
which is used such as in:
exec(http(“request”)
.get("/the/uri")
.check(pagename.is(“MY_PAGE”))
This leads to a type mismatch error:
found : io.gatling.core.check.CheckBuilder[_1,_2,String] where type _2 >: jodd.lagarto.dom.NodeSelector with String <: Object, type _1 >: io.gatling.core.check.css.CssCheckType with io.gatling.core.check.regex.RegexCheckType <: Object
required: io.gatling.http.check.HttpCheck
Looks like the type inference is fumbling - or should I explicitly declare the return type for the pagename function? And which type, then?
I tried explicitly declaring the return type to an HttpCheck:
val pagename : HttpCheck = if ( version >= SemanticVersion(“3.2.0”) ) pagenameVersion32OrMore else pagenameVersion31OrLess
But then:
value is is not a member of io.gatling.http.check.HttpCheck
Any clue, anyone?
Thanks a million
Pascal D