Unit Testing

When writing code, it can be hard to know (let alone prove) that the code you wrote does the right thing. Does it handle input correctly? Does it fail gracefully when it’s given bad data? Does it deal with edge cases the way you expected?


This is a companion discussion topic for the original entry at https://happycoding.io/tutorials/java/unit-testing

I think the syntax used in the Verification section is slightly off or maybe this was an older syntax. Only the object should go inside the verify() function parenthesis and then the function being verified should come outside the verify().

Correct:
Mockito.verify(mockDataConnection).setResult(42);
Old:
Mockito.verify(mockDataConnection.setResult(42));