简体   繁体   中英

AssertJ solution for Mockito.verify

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?

不,AssertJ 只是一个断言库,而不是一个模拟库,未来没有提供模拟的计划,因为 Mockito 已经在这方面做得很好。

I tried something like this:

SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(someValue).isNull();
        softly.assertThatCode(() -> verify(mockedInstance).someCall(eq("argument")))
              .doesNotThrowAnyException();
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM