Spring-boot: BDDMockito does not seem to be able to mock void methods

Created on 12 Sep 2016  路  2Comments  路  Source: spring-projects/spring-boot

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.

invalid

Most helpful comment

You need something like this:

willThrow(new JMSException("Could not start", "123")).given(connection).start();

All 2 comments

You need something like this:

willThrow(new JMSException("Could not start", "123")).given(connection).start();

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dsyer picture dsyer  路  40Comments

dsyer picture dsyer  路  32Comments

Brandon-Godwin picture Brandon-Godwin  路  35Comments

philwebb picture philwebb  路  33Comments

snicoll picture snicoll  路  37Comments