[육선우] sprint7#156
Hidden character warning
Conversation
…ser and Channel api
…dd UserAuthApi and ReadStatusApi
|
Merge 하려는 브랜치 변경 부탁드려요. |
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/api/binaryContents") | ||
| public class BinaryContentController implements BinaryContentApi { |
There was a problem hiding this comment.
AOP를 활용해서 Reqeust, Response에 대한 로깅을 해보면 어떨까요?!?
| datasource: | ||
| url: jdbc:postgresql://localhost:5432/discodeit | ||
| username: discodeit_user | ||
| password: discodeit1234 |
There was a problem hiding this comment.
환경 별로 동일한 데이터베이스 계정명이더라도 비밀번호를 다르게 하는것을 권장드려요.
보안적인 측면에서 문제가 발생할 수 있어서요.
|
|
||
| jpa: | ||
| hibernate: | ||
| ddl-auto: update |
There was a problem hiding this comment.
update 보다는 validate를 활용하는 것을 권장드려요.
의도치 않은 동작에 의해 운영중인 데이터베이스 DDL이 변경되어 문제가 발생할 수 있어서요.
예) MySQL 데이터타입과 JAVA 간 데이터타입이 완벽하게 호환이 안되기 때문에 데이터타입 불일치 문제로 오류 발생 가능성
| @@ -0,0 +1,60 @@ | |||
| spring: | |||
There was a problem hiding this comment.
공통되는 부분 별도로 yaml 파일 선언하신 부분 👍👍👍👍
| import org.springframework.test.web.servlet.MockMvc; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @SpringBootTest |
There was a problem hiding this comment.
선언하신 4가지 애노테이션을 포함하는 커스텀 애노테이션을 선언해보시면 어떨까요??
@IntegrationTEST 와 같이 선언하여 사용한다면 다른 개발자들이 해당 애노테이션을 봤을 때 어떤 동작을 할 수 있는지 파악가능하며, 재사용 할 수 있는 장점이 있습니다.
|
|
||
| @Test | ||
| @DisplayName("통합 유저 생성 및 전체 목록 조회 성공") | ||
| void user_Integration_Success() throws Exception { |
There was a problem hiding this comment.
통합 유저 생성 API, 전체 목록 조회 API 로 분리하여 호출하면 좋을 것 같아요.
또한 하나의 테스트 메서드에 2가지 역할이 부여된 것 같아 나누면 좋을 듯합니다.
통합 유저 생성 테스트
전체 목록 조회 테스트
2번째 전체 목록 조회 테스트는 given 조건에 통합 유저 생성이 필요하기 때문에 2가지 API를 호출하는 방식으로 구현되어야 할 것 같습니다.
// given
통합 유저 생성 API 호출
// when
전체 목록 조회 API 호출
// then
검증
| @DataJpaTest | ||
| @ActiveProfiles("test") | ||
| @EnableJpaAuditing | ||
| class UserRepositoryTest { |
There was a problem hiding this comment.
보통 현업에서는 JPA가 제공하는 메서드는 테스트코드로 작성하지 않는다는 점 참고 부탁드려요.
저 같은 경우에는 QueryDSL이라는 QueryBuilder 라이브러리를 통해 여러 테이블을 조인하는 쿼리를 작성하는데 해당 쿼리를 검증하기 위한 테스트 코드를 작성합니다.
|
|
||
| @Test | ||
| @DisplayName("채널 생설 성공") | ||
| void createPublicChannelSuccess() throws Exception { |
There was a problem hiding this comment.
Controller 영역의 테스트는 Request, Response에 대한 필드 검증을 주로 진행하는 점 참고 부탁드려요.
| private BasicChannelService channelService; | ||
|
|
||
| @Test | ||
| @DisplayName("PUBLIC 채널 생성 성공") |
There was a problem hiding this comment.
Mocking은 테스트 코드가 외부 환경에 의존되는 부분을 단절하는 개념에서 많이 사용하는 점 참고 부탁드려요.
여기에서는 데이터베이스라는 외부 환경을 단절합니다.
| import com.sprint.mission.discodeit.entity.BinaryContent; | ||
| import java.util.Map; | ||
|
|
||
| public class BinaryContentException extends DiscodeitException { |
There was a problem hiding this comment.
Exception을 구분하기 위한 하나의 방안으로 패키지를 세분화하여 Exception을 포함하는 방안이 있습니다.
프로젝트가 커지면 커질수록 너무 많은 Exception들이 존재합니다.
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게