[Solved] org.mockito.exceptions.misusing.RedundantListenerException

RedundantListenerException is RuntimeException and sub class of MockitoException. This occurred by Mockito framework when  instance of MockitoListener is being added to Mockito Framework and there is already a listener with this implementation type registered.

Note : It is ok to add multiple different implementations of the same listener interface type.

Constructors

  • RedundantListenerException(String message) : Will throw exception with message.

Example

MockitoFramework.addListener(MockitoListener);

Solutions

If you are trying to add the listener but a listener of the same type was already added (and not removed) this method will throw RedundantListenerException. This is a safeguard to ensure users actually remove the listeners via removeListener</strong>. We do not anticipate the use case where adding the same listener type multiple times is useful.

References

https://static.javadoc.io/org.mockito/mockito-core/2.6.5/org/mockito/exceptions/misusing/RedundantListenerException.html

Know More

To know more about Junit, Mockito and exception solutions follow below links:

Advertisements

This site uses Akismet to reduce spam. Learn how your comment data is processed.