Test API REST SCALA

scala, testing

Solution

With the help of @jmccure and also another question on SO and this blog I find the way to do it.

For example, this is how my first test looks like:

test("Create User") {
 Post("/users", user) ~> userRoutes ~> check {
  assert(
    status == OK
    && responseAs[User] == user
   ) 
  }
}

Where `user` is a case class that can be marshalled.

Problem

I am developing an application with Scala, Akka and Spray and I want to test the services of the API. I do not understand how`spray-testkit` helps us in testing. I also tried `Specs2` and `ScalaTest` but neither of them are made to test APIs. I just want a library that allow me to test API paths, adding headers, jsons to body and assert HTTP status and so son. What do you suggest me? [EDIT] I also tried Frisby.js and it is more simple. Maybe it is a better choice. [EDIT -2] I found Gatling. Does anyone know it?? Thanks!

Original source

Related problems