@ActiveProfiles 란?

무지성개발자·2023년 10월 8일
0

@ActiveProfiles

@ActiveProfiles는 테스트코드 실행시 profile환경을 지정해주는 것이다.

일반적으로 properties파일 또는 Bean설정 등을 profile환경 별로 나눠 주는데 테스트 환경에서 profile을 적용해서 테스트 할 수 있도록 해주는 것이다.

코드 테스트

properties 파일에 profile을 설정 후 테스트 코드에서 @ActiveProfiles로 테스트 해봤다.
테스트 코드 proflie을 제대로 설정하지 않거나 없으면 Injection of autowired dependencies failed에러가 난다.


한 줄평 : -Dspring.profiles.active= 로 실행 후 테스트 했었는데.. @ActiveProfiles를 사용하면 테스트하기 아주 편하다.

profile
no-intelli 개발자 입니다. 그래도 intellij는 씁니다.

0개의 댓글