Is there a way to use AssertJ assertions with Spring MVC Test?

后端 未结 3 1579
情话喂你
情话喂你 2021-02-07 04:07

I have been using AssertJ for some time in my projects. Recently I started using Spring MVC Test for testing Spring MVC controllers.

But I am not getting how to use Ass

3条回答
  •  渐次进展
    2021-02-07 04:49

    Update

    If you would like to vote for inclusion of support for AssertJ assertions with MockMvc, please see the related Spring JIRA issue: SPR-16637.


    Generally speaking, you may choose whatever assertion framework you like when testing with Spring.

    However, the particular scenario you are describing involves the API of the Spring MVC Test framework. The methods in question are designed to be used with the Hamcrest Matcher API. It is therefore not possible to use AssertJ within those method calls.

    Regards,

    Sam (author of the Spring TestContext Framework)

提交回复
热议问题