Skip to content

Instantly share code, notes, and snippets.

@LeoHeo
Last active April 22, 2018 04:43
Show Gist options
  • Save LeoHeo/b41db3139eaea420e0250543c1072cd3 to your computer and use it in GitHub Desktop.
Save LeoHeo/b41db3139eaea420e0250543c1072cd3 to your computer and use it in GitHub Desktop.
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class UserControllerTests {
// injection 코드들 생략...
@Test
public void 인자가_아무것도_없을때_400() throws Exception {
this.mockMvc.perform(post("/user/signup"))
.andExpect(status().isBadRequest());
}
@Test
public void 골뱅이가 없는 이메일_format_400() throws Exception {
UserSaveDto userSaveDto = new UserSaveDto();
userSaveDto.setUsername("hjh");
userSaveDto.setAddress("seoul");
userSaveDto.setPassword("123456");
userSaveDto.setEmail("hjh544");
userSaveDto.setProvider(Provider.create("test"));
this.mockMvc.perform(
post("/user/signup")
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(userSaveDto)))
.andExpect(status().isBadRequest());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment