Skip to content

Support varargs for expectations in MockMvc [SPR-16417] #20963

@spring-projects-issues

Description

@spring-projects-issues

Valeriy Zhirnov opened SPR-16417 and commented

The current way of writing multiple expect statements is kinda verbose:

mockMvc.perform(get("/person/1"))
  .andExpect(status().isOk())
  .andExpect(content().contentType(MediaType.APPLICATION_JSON))
  .andExpect(jsonPath("$.person.name").value("Jason"));

I propose vararg method that can do the same in a slightly cleaner way using default interface method:

mockMvc.perform(get("/person/1"))
  .andExpect(
    status().isOk(),
    content().contentType(MediaType.APPLICATION_JSON),
    jsonPath("$.person.name").value("Jason")
  );

the pull reuest are at github by the link in reference url


Affects: 5.0.3

Reference URL: #1651

Issue Links:

Referenced from: commits c57e1af

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions