If anyone came to this question looking for ways to add multiple parameters at the same time (my case), you can use .params
with a MultivalueMap instead of adding each .param
:
LinkedMultiValueMap<String, String> requestParams = new LinkedMultiValueMap<>()
requestParams.add("id", "1");
requestParams.add("name", "john");
requestParams.add("age", "30");
mockMvc.perform(get("my/endpoint").params(requestParams)).andExpect(status().isOk())