gpt4 book ai didi

scala - 使用testkit对akka进行gradle测试

转载 作者:行者123 更新时间:2023-12-03 03:18:20 27 4
gpt4 key购买 nike

我有一个Scala + Akka + Gradle应用程序,并进行了以下测试:

class UserCRUDSpec() extends TestKit(ActorSystem("UserCRUDSpec"))
with ImplicitSender
with WordSpecLike
with Matchers
with Mockito
with DomainSuit {

val userDao: UserDao = mock[UserDao]
val actor: ActorRef = system.actorOf(UserCRUD.props(self, userDao))

"The UserCRUD actor " must {

"search actor by id if actorId specified and exists" in {
...
}

}

}

和gradle build.gradle依赖项:
    apply plugin: 'scala'

dependencies {
compile 'org.scala-lang:scala-compiler:2.12.6'
compile('com.typesafe.akka:akka-cluster_2.12:2.5.14') {
exclude group: 'org.scala-lang'
}
testCompile ('com.typesafe.akka:akka-testkit_2.12:2.5.14') {
exclude group: 'org.scala-lang'
}
testCompile ('org.scalatest:scalatest_2.12:3.0.5') {
exclude group: 'org.scala-lang'
}
testCompile ('org.specs2:specs2-core_2.12:4.3.3') {
exclude group: 'org.scala-lang'
}
testCompile ('org.specs2:specs2-mock_2.12:4.3.3') {
exclude group: 'org.scala-lang'
}
}
}

当我运行 ./gradle test时,它说未找到测试。有什么方法可以添加TestKit测试以使 gradle test任务可见?

最佳答案

最后,我只是切换到了scalatest和指定的actor系统:

class UserCRUDSpec() extends WordSpec with TestKitBase ... {
...
implicit lazy val system: ActorSystem = ActorSystem("UserCRUDSpec")
...
}

关于scala - 使用testkit对akka进行gradle测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51825817/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com