我尝试了六种不同的方法,但我似乎无法修改演员问题的默认超时值。这意味着它几乎总是在CI服务器上失败。
这是我当前的迭代。有几种尝试捆绑在一起。他们都没有做任何事情来修改1秒的超时值。
基础测试类
import akka.actor.ActorSystem
import akka.testkit.TestKit
import com.typesafe.config.ConfigFactory
import org.specs2.mutable.SpecificationLike
import org.specs2.specification.AfterEach
import org.specs2.specification.core.Fragments
abstract class TestActors
extends TestKit(ActorSystem("testsystem", ConfigFactory.load("test-application.conf")))
with SpecificationLike
with AfterEach {
override def map(fs: => Fragments) = super.map(fs) ^ step(system.terminate, global = true)
def after = system.terminate()
}
规格
class RepoSpec(implicit ee: ExecutionEnv) extends TestActors {
isolated
implicit val timeout = Timeout(5 seconds)
val repo = system.actorOf(Props(classOf[Repo], data))
"return None when there's no such record" >> {
implicit val timeout = Timeout(30 seconds)
val record = repo ? GetRecord(1, RecordKey(1, 1, 1))
record must beEqualTo(Option.empty[Record]).await
}
}
的src /测试/资源/测试application.conf
akka.test {
timefactor=10
single-expect-default=5000
}
规格在我的笔记本电脑上完成,但在Travis上失败:
[error] x return None when there's no such record
[error] Timeout after 1 second (retries = 0, timeout = 1 second), timeFactor = 1 (TestActors.scala:10)
编辑:奇怪的是错误消息中引用的行是TestActors.scala:10
- 这是基本测试类的类定义。
如果我能让系统明白1秒太快,我会非常高兴。