scala - Testing Akka with Specs2 -
i have next specs2 test:
package concurrent import akka.actor.{props, actorref2scala} import akka.testkit.testactorref import scala.concurrent.duration._ class messagecoordinatingactorspec extends actorbasespec { "messagecoordinatingactor" should { "receive result , update related token , status" in { val (repositoryactorprobe, messagecoordinatingactorref) = buildmockmessagecoordinatingactor val addresses = mocksession.gettestaddresseswithservicesat( "16 main street", list("service1", "service2")) val postcode = postcode("ne28 9qr", addresses) val matchedaddr = addresses.find(_.addrtoken=="16 main street") messagecoordinatingactorref ! result(lookupresult( lookupstatus.servicesavailable, postcode, matchedaddr, true), testrecord) //expect message persist virgin postcode record repositoryactorprobe.expectmsg(pairlongtoduration(3, seconds), persistpostcode(postcode)) 1 mustequal 1 } } } abstract class actorbasespec extends testkit(actorsystem("test")) implicitsender mustmatchers specificationlike mockito { //this class contains fixture mill methods //such buildmockmessagecoordinatingactor }
the content of test pretty unimportant question, have 2 problems. firstly notice had utilize
pairlongtoduration(3, seconds)
i want able utilize
3.seconds (from scala.concurrent.duration package)
but when do, next error:
[error] found : org.specs2.time.duration [error] required: scala.concurrent.duration.finiteduration
any thought how can around this?
also notice had stick
1 mustequal 1
at bottom. if take out get
[error] /users/.../messagecoordinatingactorspec.scala:18: not find implicit value evidence parameter of type org.specs2.execute.asresult[concurrent.repositoryactor.updateaddrtoken]
it seems specs2 not recognise probe.expectmsg success beingness test success, there way prepare in more satisfactory way?
cheers! nfv
you need mix in org.specs2.time.notimeconversions
trait duration issue.
then can create implicit instance asresult[updateaddrtoken]
typeclass:
implicit def tokenasresult = new asresult[updateaddrtoken] { def asresult(r: =>updateaddrtoken) = success }
scala akka specs2
No comments:
Post a Comment