首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用testkit对akka进行gradle测试

使用testkit对akka进行gradle测试
EN

Stack Overflow用户
提问于 2018-08-13 23:29:55
回答 1查看 212关注 0票数 2

我有一个Scala + Akka + Gradle应用程序和以下测试:

代码语言:javascript
复制
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依赖:

代码语言:javascript
复制
    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时,它显示找不到任何测试。有没有办法添加对gradle test任务可见的TestKit测试?

EN

回答 1

Stack Overflow用户

发布于 2018-08-14 23:42:16

最后,我刚刚切换到scalatest和指定的参与者系统:

代码语言:javascript
复制
class UserCRUDSpec() extends WordSpec with TestKitBase ... {
  ...
  implicit lazy val system: ActorSystem = ActorSystem("UserCRUDSpec")
  ...
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51825817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档