O'Reilly logo

Building Applications with Scala by Diego Pacheco

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 with Play framework support

Now we will continue building our application. Let's add BDD tests in our application. We will start doing tests for your services. We have to test ProductService, ImageService, and ReviewService.

Your ProductServiceTestSpec.scala file should contain the following code:

 class ProductServiceTestSpec extends PlaySpec { "ProductService" must { val service:IProductService = new ProductService "insert a product properly" in { val product = new models.Product(Some(1), "Ball","Awesome Basketball",19.75) service.insert(product) } "update a product" in { val product = new models.Product(Some(1), "Blue Ball","Awesome Blue Basketball",19.99) service.update(1, product) } "not update because does not exit" in { intercept[RuntimeException]{ ...

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