I have a post spray-am route to try to test with Skelatst requiring mandatory parameter adId for . And it can not work my code
import akka.actor._ import akka.event.LoggingReceive import akka.testkit {} TestProbe Import com.ss.rg.service.ad.AdImporterServiceActor {GetImportStatus, StatusOfImport is as} Import org.scalatest. {MustMatchers, WordSpecLike} Import Spray. Http. {StatusPodes, MediaTypes} Import spray.testkit.ScalatestRouteTest class with AdServiceApiTest ScalatestRouteTest to import Extended {"AdService REST API" with WordSpecLikeMasterMatchers {{"POST POST with mandatory mandatory parameters"} {Val P = TestProbe () Val addressServiceMock = System.actorOf (Props (classOf [AdServiceActorMock], p.ref)) Post ("/ service / advertising / import") ~> should fail; New AdServiceApi (addressServiceMock) .route ~ & gt; Testing should be in the (wrong) position (StatusCodes.BadRequest)}}
The test fails but for a different reason
request was rejected list (MissingQueryParamRejection (adid)) org.scalatest.exceptions.TestFailedException: (MissingQueryParamRejection (adid)) was rejected with (ScalatestInterface request list spray.testkit.ScalatestInterface $ class.failTest. scala: 25) com.ss.rg.api.ad.AdServiceApiTest.failTest (on AdServiceApiTest.scala: spray.testkit.RouteResultComponent $ RouteResult 19 to $$ anonfun $) reaction $ 1 $$ anonfun $ $ 1.Apply (RouteResultComponent Applicable .scala: spring Of 236): scala.Option.foreach (95) on Option.scala: 97) react spray.testkit.RouteResultComponent $ RouteResult $$ anonfun $ apply $ 1 $$ anonfun $ $ 1.Apply (RouteResultComponent.scala. Testkit.RouteResultComponent $ RouteResult $$ $ $ Apan reaction $ 1.apply (RouteResultComponent.scala: 94) ...
it seems that the situation is even went not examine other thing that I'm not completely clean, how does he actually set an ad parameter in the spray-testkit? One way would be to set the header, but I would not be surprised that the better way would be present.
Can the spray-turskit experience someone else with the comment?
Thx
No status - route request > Disclaimer and claim that this is the type you want for you if you want to see what the browser really sees, then you use the default RejectHandler
You should wrap the route in a handleRejections
instruction (it is available sloppy) and then you enable Will be in a position to see the expected status code handled
but true will come out as
(as it will handle wrapped Route request - failed Stetsod and an error message With back a response).
No comments:
Post a Comment