강의

멘토링

커뮤니티

Inflearn Community Q&A

anaconda3iot0353's profile image
anaconda3iot0353

asked

Spring Core Principles - Basic Edition

Separation of Concerns

Test 코드에서 this.memberService 질문

Written on

·

216

0

Test Code 부분에서 궁금한점이 생겨 질문 남깁니다.

Test Code에서는

this.memberService = appConfig.memberService();

로 사용하는 것과 차이점이 있나요?

this.memberService = appConfig.memberService();

memberService = appConfig.memberService();

둘다 실행해봤을 때는 정상적으로 테스트 통과하긴 합니다

 

springoop

Answer 1

2

안녕하세요. gang ho lee님, 공식 서포터즈 David입니다.

위 코드를 기준으로 말씀드리면, this.를 붙이나 안 붙이나 동일하게 동작합니다.

다만, 명시적으로 클래스의 멤버를 사용하는 걸 드러내고 싶을 때 this.를 붙이기도 합니다.

감사합니다.

anaconda3iot0353's profile image
anaconda3iot0353

asked

Ask a question