How to test if JSON path does not include a specific element, or if the element is present it is null?

前端 未结 5 1311
野趣味
野趣味 2021-02-04 23:17

I have been writing some simple unit testing routines for a simple spring web application. When I add @JsonIgnore annotation on a getter method of a resource, the resulting json

5条回答
  •  孤街浪徒
    2021-02-04 23:39

    I had the same problem with the newer version. It looks to me that the doesNotExist() function will verify that the key is not in the result:

    .andExpect(jsonPath("$.password").doesNotExist())
    

提交回复
热议问题