You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
섹션3. 회원 관리 예제 - 백엔드 개발
1. 비즈니스 요구 사항 정리
데이터 : 회원 ID, 이름
기능 : 회원 등록, 조회
데이터 저장소는 아직 미정
컨트롤러
웹 MVC의 컨트롤러 역할
서비스
핵심 비즈니스 로직 구현
리포지토리
도메인 객체를 DB에 저장하고 관리
도메인
비즈니스 도메인 객체( DB에 저장하고 관리됨)
Member 라는 하나의 도메인과 연관된 MemberService , MemberRepository , MemoryMemberRepository 가 의존관계를 가지고 있다.
2.회원 도메인과 리포지토리 만들기
package hello.hellospring.domain
회원 객체 생성(Member)
package hello.hellospring.repository
회원 repository 인터페이스 및 구현체 생성 (MemberRepository, MemoryMemberRepository)
3. 회원 리포지토리 테스트 케이스 작성
자바는 JUnit 프레임워크로 테스트를 실행한다.
given , when , then 의 구조로 테스트를 짜면 테스트 코드를 파악하기 좋다
@AfterEach
메모리 DB에 직전 테스트의 결과가 남아 다은 테스트에 영향을 끼치는 일이 발생하지 않도록 도와준다.
각 테스트가 종료될 때 마다 DB에 저장된 데이터를 삭제한다.
테스트는 독립적으로 실행되어야 한다.
4. 회원 서비스 개발
Optional
값이 없는 경우를 표현하기 위한 클래스이다.
제네릭을 사용하여 어떤 타입의 객체도 감싸서 담을 수 있다.
https://ccomccomhan.tistory.com/127
5. 회원 서비스 테스트
@beforeeach
각 테스트의 실행 전에 호출되어, 테스트가 서로 영향이 없도록 항상 새로운 객체를 생성하고 의존관계를 맺는다.
Beta Was this translation helpful? Give feedback.
All reactions