spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.91k stars 40.62k forks source link

BDDMockito does not seem to be able to mock void methods #6869

Closed snicoll closed 8 years ago

snicoll commented 8 years ago

In https://github.com/spring-projects/spring-boot/commit/b88cb35ea231fffa807a9f1d97b6b38e412bb34b I had to mock a void method (throw an exception if it's invoked). I haven't found a way to do that with the bdd imports so I've tricked by a full import.

What am I missing? We need to fix that commit with the proper way of doing this or change the checkstyle rules.

wilkinsona commented 8 years ago

You need something like this:

willThrow(new JMSException("Could not start", "123")).given(connection).start();
snicoll commented 8 years ago

That's what I am doing right now. Oh no I am not. willThrow :|