반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 무화과
- 치비
- 애플 달팽이
- for
- 쌈채소
- 반복문
- Config server
- Tendermint
- 가재
- 구피
- Python 강좌
- 체리새우
- 분산 신원
- 주말농장
- 분산 식별자
- rust 소개
- MSA
- rust 강좌
- 텐더민트
- 물생활
- 기본문법
- rust
- Feign
- RSA
- 카디날
- golang 강좌
- PKI
- MSSQL
- 조건문
- did
Archives
- Today
- Total
comnic's Dev&Life
Spring boot로 Rest Test를 위한 간단한 소스 본문
반응형
Spring boot로 Rest Test를 위한 간단한 소스
기본적으로 생성된 Test Class를 상속 받아 사용한다.
아래 코드에서는 ApiServerApplicationTests Class가 자동으로 생성된 Class이다.
public class TestWebApp extends ApiServerApplicationTests {
@Autowired
private WebApplicationContext webApplicationContext;
private MockMvc mockMvc;
@Before
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Test
public void testUsers() throws Exception {
mockMvc.perform(get("/users")).andExpect(status().isUnauthorized());
// .andExpect(content().contentType("application/json;charset=UTF-8"))
// .andExpect(jsonPath("$.name").value("emp1")).andExpect(jsonPath("$.designation").value("manager"))
// .andExpect(jsonPath("$.empId").value("1")).andExpect(jsonPath("$.salary").value(3000));
}
}
반응형
'JAVA & Spring' 카테고리의 다른 글
| [Thymeleaf]값 출력 방법 정리 (1) | 2019.04.30 |
|---|
Comments