package silentactor03 {
class SilentActorTest extends TestKit(ActorSystem("testsystem"))
with WordSpecLike
with MustMatchers
with StopSystemAfterAll {
"A Silent Actor" must {
"change internal state when it receives a message, multi" in {
import SilentActor._ //import protocol
val silentActor = system.actorOf(Props[SilentActor], "s3") //create actor"/>
silentActor ! SilentMessage("whisper1")
silentActor ! SilentMessage("whisper2")
silentActor ! GetState(testActor) //get state
expectMsg(Vector("whisper1", "whisper2")) //expectMsg
}
}
}
object SilentActor {
case class SilentMessage(data: String)
case class GetState(receiver: ActorRef) //getstate msg"/>
}
class SilentActor extends Actor {
import SilentActor._
var internalState = Vector[String]()
def receive = {
case SilentMessage(data) =>
internalState = internalState :+ data
case GetState(receiver) => receiver ! internalState //process getstate msg
}
}
}
[info] A Silent Actor
[info] - must change internal state when it receives a message, multi *** FAILED ***
[info] java.lang.AssertionError: assertion failed: expected Succeeded, found Vector(whisper1, whisper2)
[info] at scala.Predef$.assert(Predef.scala:165)
[info] at akka.testkit.TestKitBase$class.expectMsg_internal(TestKit.scala:351)
[info] at akka.testkit.TestKitBase$class.expectMsg(TestKit.scala:327)
[info] at akka.testkit.TestKit.expectMsg(TestKit.scala:735)
[info] at com.thespidernet.scalablog.models.silentactor03.SilentActorTest$$anonfun$2$$anonfun$apply$mcV$sp$2.apply(akkaSuite.scala:117)
[info] at com.thespidernet.scalablog.models.silentactor03.SilentActorTest$$anonfun$2$$anonfun$apply$mcV$sp$2.apply(akkaSuite.scala:110)
[info] at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
[info] at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
[info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info] at org.scalatest.Transformer.apply(Transformer.scala:22)
[info] ...
The werid part to me is - that the test reads that it expects the "Vector(whisper1, whisper2)" result - which the error message says it is actually getting - but somehow - states that the test is expecting "Success".
So at a very brief look - I don't understand the error.
-Gavin.
Hi Gavin,
I just got off a long flight. On my phone only right now,
But it looks like our Compatibility implicit conversion from Any => Assertion was applied inside the parameter list of expectMsg call. This conversion "discards" the vector value by placing ; Succeeded after it. Once I get to the hotel I'll try and understand why that conversion was triggered in that spot.
Bill
--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.