I want to test that calling a given method on my s...
# testing
a
I want to test that calling a given method on my subject/unit under test calls a given method on a mock, with any lambda as an argument. However if I do this:
Copy code
subject.openThePodBayDoors()

verify(mockDoorManager).completion(Mockito.any())
...then I get an error:
Copy code
java.lang.IllegalStateException: Mockito.any() must not be null
...even though I have written the production code which should make this test pass. I’ve been googling “kotlin mockito match any lambda” etc. and can find complex tests with
LambdaMatcher
but all I want to do is check that the method was called with some lamba - I don’t even care what it does for this test. There must be a simple solution for this I’m missing, surely?
I’ve also tried:
Copy code
verify(mockDoorManager).completion(argThat(ArgumentMatcher { true } ))
...but get exactly the same runtime error