AssertJ solution for Mockito.verify

Viewed 4570

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?

2 Answers

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();
    });
Related