使用scalatest测试akka时找不到测试用例,我应该怎么做才能更正它?
Could not find test case when using scalatest to test akka, what should i do to correnct it?
刚接触akka和scalatest,正在按照akka的文档学习。但是想测试一下官网说的demo代码,好像不行well.The测试代码如下
package com.example
import akka.actor.ActorSystem
import akka.actor.testkit.typed.scaladsl.ScalaTestWithActorTestKit
import akka.testkit.TestProbe
import org.scalatest.WordSpecLike
class IotTest extends ScalaTestWithActorTestKit with WordSpecLike {
"Iot actor system" must {
"reply with empty reading if no temperature is known" in {
implicit val system: ActorSystem = ActorSystem("Iot")
val probe = TestProbe()
val deviceActor = system.actorOf(Device.props("group", "device"))
deviceActor.tell(Device.ReadTemperature(requestId = 42), probe.ref)
val response = probe.expectMsgType[Device.RespondTemperature]
response.requestId should ===(42L)
response.value should ===(None)
}
}
}
当我在命令行运行sbt和运行testOnly IotTest
命令时,响应如下
[info] Done compiling.
[info] Run completed in 9 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] No tests to run for Test / testOnly
[success] Total time: 3 s, completed 2019-11-1 10:33:41
sbt:akka-quickstart-scala>
目录结构是这样的
│ build.sbt
│ list.txt
│ sbt
│ sbt.bat
├─.idea
├─project
├─sbt-dist
├─src
│ ├─main
│ │ └─scala
│ │ └─com
│ │ └─example
│ │ ActorFailureHandling.scala
│ │ ActorHierarchyExperiments.scala
│ │ ActorLifecycle.scala
│ │ AkkaQuickstart.scala
│ │ Device.scala
│ │ DeviceGroup.scala
│ │ DeviceGroupQuery.scala
│ │ DeviceManager.scala
│ │ IotApp.scala
│ │ IotSupervisor.scala
│ │
│ └─test
│ └─scala
│ └─com
│ └─example
│ AkkaQuickstartSpec.scala
│ IotTest.scala
│ ScalaTestIntegrationExampleSpec.scala
│
└─target
根据响应,没有测试用例运行。我很困惑,如果你能帮我一个忙,我将不胜感激。
您应该使用完整的测试名称。 testOnly some.package.name.TestName
或 testOnly *TestName
.
刚接触akka和scalatest,正在按照akka的文档学习。但是想测试一下官网说的demo代码,好像不行well.The测试代码如下
package com.example
import akka.actor.ActorSystem
import akka.actor.testkit.typed.scaladsl.ScalaTestWithActorTestKit
import akka.testkit.TestProbe
import org.scalatest.WordSpecLike
class IotTest extends ScalaTestWithActorTestKit with WordSpecLike {
"Iot actor system" must {
"reply with empty reading if no temperature is known" in {
implicit val system: ActorSystem = ActorSystem("Iot")
val probe = TestProbe()
val deviceActor = system.actorOf(Device.props("group", "device"))
deviceActor.tell(Device.ReadTemperature(requestId = 42), probe.ref)
val response = probe.expectMsgType[Device.RespondTemperature]
response.requestId should ===(42L)
response.value should ===(None)
}
}
}
当我在命令行运行sbt和运行testOnly IotTest
命令时,响应如下
[info] Done compiling.
[info] Run completed in 9 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] No tests to run for Test / testOnly
[success] Total time: 3 s, completed 2019-11-1 10:33:41
sbt:akka-quickstart-scala>
目录结构是这样的
│ build.sbt
│ list.txt
│ sbt
│ sbt.bat
├─.idea
├─project
├─sbt-dist
├─src
│ ├─main
│ │ └─scala
│ │ └─com
│ │ └─example
│ │ ActorFailureHandling.scala
│ │ ActorHierarchyExperiments.scala
│ │ ActorLifecycle.scala
│ │ AkkaQuickstart.scala
│ │ Device.scala
│ │ DeviceGroup.scala
│ │ DeviceGroupQuery.scala
│ │ DeviceManager.scala
│ │ IotApp.scala
│ │ IotSupervisor.scala
│ │
│ └─test
│ └─scala
│ └─com
│ └─example
│ AkkaQuickstartSpec.scala
│ IotTest.scala
│ ScalaTestIntegrationExampleSpec.scala
│
└─target
根据响应,没有测试用例运行。我很困惑,如果你能帮我一个忙,我将不胜感激。
您应该使用完整的测试名称。 testOnly some.package.name.TestName
或 testOnly *TestName
.