Search code examples
javamockitomatcher

How to write a matcher that is not equal to specific enum value?


As in the question, there's any way I can do it? Below code, which work for String doesn't work. I want any other value than, for example: SomeEnum.FIRST

when(mock.method(any())).thenReturn(not(eq(SomeEnum.FIRST)));

Solution

  • How about this?

    when(mock.method(any())).thenReturn(SomeEnum.SECOND);