2

I have a Scala + Akka + Gradle application and the following test:

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 {
       ...
    }

  }

}

and a gradle build.gradle dependencies:

    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'
        }
    }
}

When I run ./gradle test, it says that no tests found. Is there any way how I can add TestKit tests to be visible for gradle test task?

Alexander Davliatov
  • 723
  • 2
  • 8
  • 13

1 Answers1

1

Finally, I just switched to scalatest and specified actor system:

class UserCRUDSpec() extends WordSpec with TestKitBase ... {
  ...
  implicit lazy val system: ActorSystem = ActorSystem("UserCRUDSpec")
  ...
}
Alexander Davliatov
  • 723
  • 2
  • 8
  • 13