What is the best way to override a field in a base simulation? I thought it would be just a matter of subclassing and overriding the value.
class Base extends Simulation {
val baseUrl = “http://gatling.io”
val httpProtocol = http.baseURL(baseUrl)
}
class Sub extends Base {
override val baseUrl = “http://jmeter.apache.org/”
}
testOnly Sub
Thanks
I’m new to scala, but in Java you would need to define a getter to be able to achieve this - the getter can be overridden, static values cannot.
DON’T override vals. Just like in Java with members, there’s a very good chance you’ll end up shooting yourself in the foot.
If you really want to use inheritance (composition is WAY better) and want to override, use defs (methods) instead.