Book-Microservices-v2 / chapter07

Learn Microservices with Spring Boot (2nd edition) - Chapter 7
https://tpd.io/book-extra
8 stars 13 forks source link

Test GameEventHandler #2

Open andreykirson opened 3 years ago

andreykirson commented 3 years ago

Hi, in your book, you recommend creating a test for a new Game Event Handler class. You have an implementation of this test, because I'm a little confused about how to use this instruction to create a test for the consumer https://docs.spring.io/spring-amqp/reference/html/#test-harness

mechero commented 3 years ago

Hi Andrey, good question! I haven't written tests using those Spring AMQP tools yet. What I had in mind is mocking the GameService operation and invoking the handleMultiplicationSolved method explicitly with an event that you can create beforehand. You can also instruct the mock to throw an exception to test the error scenario.