=tes #3727 Fix timing failure in TestTimeSpec

This commit is contained in:
Patrik Nordwall 2013-12-11 15:58:54 +01:00
parent 6ab4733fa7
commit 8e74bbdc8b

View file

@ -12,13 +12,15 @@ class TestTimeSpec extends AkkaSpec(Map("akka.test.timefactor" -> 2.0)) with Bef
"A TestKit" must {
"correctly dilate times" taggedAs TimingTest in {
1.second.dilated.toNanos must be(1000000000L * testKitSettings.TestTimeFactor)
val probe = TestProbe()
val now = System.nanoTime
intercept[AssertionError] { probe.awaitCond(false, Duration("1 second")) }
val diff = System.nanoTime - now
val target = (1000000000l * testKitSettings.TestTimeFactor).toLong
diff must be > (target - 300000000l)
diff must be < (target + 300000000l)
diff must be > (target - 500000000l)
diff must be < (target + 500000000l)
}
"awaitAssert must throw correctly" in {