Unit Tests for Product Routes Part 2
Explore how to create robust unit tests for product routes in Scala HTTP APIs. Learn to handle errors like invalid JSON and non-existing products. Understand the importance of testing with proper repository setup to ensure accurate responses without needing a live database.
We'll cover the following...
We'll cover the following...
Updating with garbage values
Here, we are testing our update product functionality with garbage JSON values. This test should return 400 Bad Request. However, if we run our test, we get an exception instead:
So let’s take a deep breath and look at our code:
As we can see, we have done no error handling at all. So maybe we should rewrite this a ...