TIL
250204 화 TIL
파란배개
2025. 2. 4. 17:48
application.yml에서
spring:
datasource:
url: jdbc:h2:mem:db_t;MODE=MySQL
여기서 mem은 메모리 db로 설정한다는 것
---
@SpringBootTest
@ActiveProfiles("test")
//서버를 띄우지 않아도 스프링이 내부적으로 네트워크에서 실행한 것처럼 작동
@AutoConfigureMockMvc
class AuthApplicationTests {
@Autowired
private MockMvc mvc;
@Test
@DisplayName("회원 가입")
void join() throws Exception {
ResultActions resultActions = mvc
.perform(
post("/api/v1/members/join")
)
.andDo(print());
resultActions
.andExpect(status().isCreated())
.andExpect(handler().handlerType(ApiV1MemberController.class))
.andExpect(handler().methodName("join"))
//jsonPath = 결과 body에 json 데이터가 있으면 값은~
.andExpect(jsonPath("$.code").value("201-1"))
.andExpect(jsonPath("$.msg").value("회원 가입이 완료되었습니다."));
}
}