From the course: Advanced Spring: Effective Integration Testing with Spring Boot

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Challenge: Write an integration test for exceptions

Challenge: Write an integration test for exceptions

From the course: Advanced Spring: Effective Integration Testing with Spring Boot

Start my 1-month free trial

Challenge: Write an integration test for exceptions

(upbeat music) - [Instructor] Up 'til now we have only tested happy path but what if things go wrong? What about edge cases? What if exceptions are thrown? In this challenge, we want you to write an integration test for exceptions. As Joshua Block stated in his book "Effective Java", "When used to the best advantage, "exceptions can improve a program's readability, "reliability, and maintainability." In this challenge, we want you to write an integration test for a custom exception we will throw in our service layer. In case when a student is not available, instead of returning null, your task is to throw a custom runtime exception, studentnotfoundexception. I suggest you to take a TDD approach by first writing failing test, then implementing exception, and refactor implementation so a test passes. This challenge should take about five to 10 minutes. When you're done or you get stuck, you can check out my solution video to see how I solved the challenge.

Contents