September 2018
Intermediate to advanced
398 pages
9h 43m
English
First, let's write the tests. We will create one test per API call, to cover all the cases. By doing so, we are going to define the URI for each case. All of the test implementations will be grouped in a test class; let's call it APISpec.
We can create the class and define the URLs of our API; at this point, the APISpec class should be as follows:
class APISpec extends PlaySpec with ScalaFutures with GuiceOneServerPerSuite {
val baseURL = s"localhost:$port/v1"
val productsURL = s"http://$baseURL/products"
val addProductsURL = s"http://$baseURL/products/add"
val productsInCartURL = s"http://$baseURL/cart/products"
def deleteProductInCartURL(productID: String) = s"http://$baseURL/cart/products/$productID" def actionProductInCartURL(productID: ...Read now
Unlock full access