Testing REST service

47 views
Skip to first unread message

Eric Liou

unread,
Jul 23, 2015, 11:38:25 PM7/23/15
to Lift

I built a simple Scala Lift application with REST endpoint.


I want to write some tests. But Lift's testing documentation is horrible :/


Everyone points to this 2012 gist https://gist.github.com/heralight/2235088

Can anyone teach me how to write a simple test? I need something like the gist example:


"process a JSON RestHelper Request" withReqFor("http://foo.com/api/info.json") in { req =>
      (WebSpecSpecRest(req)() match {
        case Full(JsonResponse(_, _, _, 200)) => true
        case other => failure("Invalid response : " + other); false
      }) must_== true
    }


I found that Lift has its WebSpec, can I use that? (WebSpec's doc is not therehttps://www.assembla.com/wiki/show/liftweb/WebSpec)


Or can anybody point me to a tutorial? I'm reaaally lost.

Eric Liou

unread,
Jul 24, 2015, 1:11:25 AM7/24/15
to Lift, erc...@gmail.com
I tried using the WebSpec. But it seems that I'm using a wrong version of specs2.

lift = 2.6
org.specs2 = 3.6.2

[error] missing or invalid dependency detected while loading class file 'WebSpec.class'.
[error] Could not access type XmlMatchers in package org.specs2.matcher,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'WebSpec.class' was compiled against an incompatible version of org.specs2.matcher.
[error] one error found
[error] (test:compileIncremental) Compilation failed
Reply all
Reply to author
Forward
0 new messages