How can I mock a void method to throw an exception?
问题 I have a structure like this: public class CacheWrapper { private Map<Object, Object> innerMap; public CacheWrapper() { //initialize the innerMap with an instance for an in-memory cache //that works on external server //current implementation is not relevant for the problem innerMap = ...; } public void putInSharedMemory(Object key, Object value) { innerMap.put(key, value); } public Object getFromSharedMemory(Object key) { return innerMap.get(key); } } And my client class (you could say it