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

Service tests

Now we will create tests for services to test them. So let's get started.

Your ProductServiceTestSpec.scala file should look like this:

 class ProductServiceTestSpec extends PlaySpec { "ProductService" must { val service:IProductService = new ProductService(new ProductMockedDao) "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]{ service.update(333,null) } } "find the product 1" in { val product = Awaits.get(5, service.findById(1)) product.get.id ...

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