Scales the passed Span
by the Double
factor returned
by spanScaleFactor
.
Scales the passed Span
by the Double
factor returned
by spanScaleFactor
.
The Span
is scaled by invoking its scaledBy
method,
thus this method has the same behavior:
The value returned by spanScaleFactor
can be any positive number or zero,
including a fractional number. A number greater than one will scale the Span
up to a larger value. A fractional number will scale it down to a smaller value. A
factor of 1.0 will cause the exact same Span
to be returned. A
factor of zero will cause Span.ZeroLength
to be returned.
If overflow occurs, Span.Max
will be returned. If underflow occurs,
Span.ZeroLength
will be returned.
IllegalArgumentException
if the value returned from spanScaleFactor
is less than zero
The factor by which the scaled
method will scale Span
s.
The factor by which the scaled
method will scale Span
s.
The default implementation of this method will return the span scale factor that
was specified for the run, or 1.0 if no factor was specified. For example, you can specify a span scale factor when invoking ScalaTest
via the command line by passing a -F
argument to Runner
.
Trait providing a
scaled
method that can be used to scale timeSpan
s used during the testing of asynchronous operations.The
scaled
method allows tests of asynchronous operations to be tuned according to need. For example,Span
s can be scaled larger when running tests on slower continuous integration servers or smaller when running on faster development machines.The
Double
factor by which to scale theSpan
s passed toscaled
is obtained from thespanScaleFactor
method, also declared in this trait. By default this method returns 1.0, but can be configured to return a different value by passing a-F
argument toRunner
(or an equivalent mechanism in an ant, sbt, or Maven build file).The default timeouts and intervals defined for traits
Eventually
andAsyncAssertions
invokescaled
, so those defaults will be scaled automatically. Other than such defaults, however, to get aSpan
to scale you'll need to explicitly pass it toscaled
. For example, here's how you would scale aSpan
you supply to thefailAfter
method from traitTimeouts
:The reason
Span
s are not scaled automatically in the general case is to make code obvious. If a reader seesfailAfter(1 second)
, it will mean exactly that: fail after one second. And if aSpan
will be scaled, the reader will clearly see that as well:failAfter(scaled(1 second))
.Overriding
spanScaleFactor
You can override the
spanScaleFactor
method to configure the factor by a different means. For example, to configure the factor from Akka TestKit's test time factor you might create a trait like this:This trait overrides
spanScaleFactor
so that it takes its scale factor from Akka'sapplication.conf
file. You could then scaleSpan
s tenfold in Akka's configuration file like this:Armed with this trait and configuration file, you can simply mix trait
AkkaSpanScaleFactor
into any test class whoseSpan
s you want to scale, like this: