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("회원 가입이 완료되었습니다."));
	}
}

'TIL' 카테고리의 다른 글

250206 수 TIL  (0) 2025.02.06
250205 수 TIL  (0) 2025.02.05
250203 월 TIL  (0) 2025.02.03
250131 금 TIL  (0) 2025.01.31
250127 월 TIL  (1) 2025.01.27