2017-09-26 6 views
0

Ich habe eine einfache Feder TestFrühling MockMvc verify Körper ist leer

@Test 
public void getAllUsers_AsPublic() throws Exception { 
    doGet("/api/users").andExpect(status().isForbidden()); 
} 

public ResultActions doGet(String url) throws Exception { 
    return mockMvc.perform(get(url).header(header[0],header[1])).andDo(print()); 
} 

Ich möchte überprüfen, ob der Antworttext ist leer. Z.B. Tun Sie etwas wie .andExpect(content().isEmpty())

Antwort

1

Ich denke, eine dieser Optionen sollte erreichen, was Sie suchen, wenn auch nicht ganz so schön wie ein isEmpty() (vom ContentResultMatchers documentation):

.andExpect(content().bytes(new Byte[0]) 

oder

.andExpect(content().string("") 
Verwandte Themen