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.
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"
Now, create the specification named
ClientsSpec
insrc/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 import code.session.ClientCache import net.liftweb.http.JsonResponse import net.liftweb.json.JsonDSL._ class ClientsSpec extends Specification { val clients = Client(1, "First", "[email protected]") :: Client(2, "Second...