O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing a REST service using Specs2

As the API is subject to change in the future, it will be nice if we could create automated tests which we can easily run to confirm that we aren't breaking anything when making such changes.

In this recipe, we'll learn how to test REST APIs using Specs2.

Getting ready

As in the previous recipes, you can duplicate the project you used earlier or you can keep modifying the same one by adding the following dependency in the build.sbt file:

"net.liftweb"       %% "lift-testkit"        % liftVersion% "test"

How to do it...

  1. Now, create the specification named ClientsSpec in src/test/scala/ code/rest using the following code:
    package code.rest import org.specs2.mutable.Specification import net.liftweb.mockweb.MockWeb._ import code.model.Client ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required