Browsing through the API of AssertJ, I didn't seem to come across anything that covers the behaviour of that of Mockito.verify. Right now my assertions are all using the AssertJ fluent API, and then there's the Mockito.verify which is kind of breaking the flow of the assertions.
Is there a similar way to verify that a method is not called, called exactly once, etc. in AssertJ that I missed?
Mockito verify() simple example It's the same as calling with times(1) argument with verify method. verify(mockList, times(1)). size(); If we want to make sure a method is called but we don't care about the argument, then we can use ArgumentMatchers with verify method.
Mockito can ensure whether a mock method is being called with reequired arguments or not. It is done using the verify() method.
Mockito verifies argument values in natural java style: by using an equals() method.
Nope, AssertJ is only an assertions library, not a mock library, there is no plan to provide mocks in the future as Mockito is already doing a great job at it.
I tried something like this:
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(someValue).isNull();
softly.assertThatCode(() -> verify(mockedInstance).someCall(eq("argument")))
.doesNotThrowAnyException();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With