lerna.testkit.akka.AkkaSpanScaleFactorSupport.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lerna-testkit_2.12 Show documentation
Show all versions of lerna-testkit_2.12 Show documentation
A library that is useful for building applications that run on Lerna Stack.
package lerna.testkit.akka
import akka.actor.ActorSystem
import akka.testkit.TestKitExtension
import org.scalatest.concurrent.ScaledTimeSpans
/** A trait that provides time scale factor integration of Akka TestKit and ScalaTest
*
* ==Overview==
* The trait can be used with [[akka.testkit.TestKit]] or other Akka classic test kits such as
* [[https://doc.akka.io/api/akka-http/current/akka/http/scaladsl/testkit/ScalatestRouteTest.html ScalaTestRouteTest]]
*
* The time scale factor can be configured by `akka.test.timefactor` in a configuration file.
*/
trait AkkaSpanScaleFactorSupport extends ScaledTimeSpans {
// No trait provides the ActorSystem in both TestKit and RouteTest
implicit val system: ActorSystem
/** Configure the ScalaTest time factor from Akka TestKit's test time factor.
*
* Configure the timefactor in your configuration file like this: `akka.test.timefactor = 3.0`
*
* See also: ScaledTimeSpans
*/
override def spanScaleFactor: Double =
TestKitExtension(system).TestTimeFactor
}