jeudi 30 janvier 2020

Mockito.verify doesn't work with Lombok @Delegate

So I experience the following behaviour when trying to verify calls on mock (same for spy) which uses Lombok @Delegate inside:

public class SomeClass {

    @Delegate
    private final Map<String, String> map;
...
}

Test:

@Mock //same for @Spy ..
private SomeClass someClassMock;

@Test
void someTest() {
    ...
    verify(someClassMock, times(0)).put(anyString(), anyString()); // <-- NullPointerException
}

Looks like Mockito doesn't understand that "put" method comes from the underlying delegated class. Any ideas how to make it work?

Aucun commentaire:

Enregistrer un commentaire