2014-07-16 4 views
1

스프레이 경로를 사용하려고하며 Spray-TestKit으로 테스트하려고합니다. 내가 사용하고 있습니다 : - 스칼라 2.10.3 - Akka 2.3.3 - 나는 경로를 정의 어디 HttpService를을 연장하는 특성을 만들 1.3.1경로를 테스트하기위한 기본 Spray-Testkit 사용이 작동하지 않습니다.

스프레이 : 나는 부분을 삭제

trait MyService extends HttpService with CoreAccess { 
    import greentee.am.endpoint.tsmsp.tsmSPJsonSupport._ 


    val myRoute = { 
    path("resources"/"ping") { 
     get { 
     complete(OK, "pong") 
     } 
    } 
    } 
} 

을 관련이없는 경로의 CoreAccess는 특성을 사용하여 ActorSystem에 액세스하는 메서드가 있으므로 Actor를 확장하는 특성입니다. 내가 테스트를 실행하려고하면

그럼 내가 테스트 사양

import MyService 
import org.specs2.mutable.Specification 
import spray.testkit.Specs2RouteTest 
import spray.http.StatusCodes._ 


class RegistrationRouteSpecification extends Specification with Specs2RouteTest with MyService { 

    def actorRefFactory = system 

    "The EndPoint " should { 
    "return Pong to a Get request to the ping" in { 
     Get("/resources/ping") ~> myRoute ~> check { 
     status === OK 
     responseAs[String] === "pong" 
     } 
    } 
    } 
} 

을 만들 (내가 배우를 확장하지 않고 특성에서 ActorSelection를 검색하는 사람 모른다), I는 컴파일 오류를 다음 얻을 :

[info] Compiling 1 Scala source to /Users/IdeaProjects/endpoint/target/scala-2.10/test-classes... 
[error] /Users/IdeaProjects/endpoint/src/test/scala/RegistrationRouteSpecification.scala:19: could not find implicit value for parameter ta: RegistrationRouteSpecification.this.TildeArrow[spray.routing.RequestContext,Unit] 
[error]  Get("/resources/ping") ~> myRoute ~> check { 
[error]         ^
[error] one error found 
+0

'MyService'코드를 표시 할 수 있습니까? – wedens

+0

안녕하세요, 설명을 수정했습니다. 그 동안, 나는 사용하고있는 스케 매틱 버전이 적합하지 않음을 알았으므로 이제 테스트를 실행할 수 있습니다! 내 형질이 배우에게서 상속 받기 때문에 실패합니다.하지만이 문제를 해결할 것입니다. 감사! – Joel

+0

동일한 이유로 경로 정의와 HttpService를 두 가지로 나눠주는 스프레이 템플릿 예제를 보았습니까? https://github.com/spray/spray-template/blob/on_spray-can_1.1/src/main/ scala/com/example/MyService.scala – jrudolph

답변

1

나는 내 자신의 질문에 대답한다. 내 Build.scala 다음 줄 사용하는 보정 대신 간단한 '%'를 사용하고 전용 버전을 공급

val scalaCheck = "org.scalacheck"    %% "scalacheck"  % Versions.scalaCheckVersion % "test" 
val scalaTest = "org.scalatest" %% "scalatest" % "2.2.0" % "test" 

합니다.

관련 문제