Spring Boot로 JPA 프로젝트를 진행하면서 페이징 기능을 구현하기 전 게시물 더미 데이터를 넣기 위해 Test를 진행하였다.
/test/repository/BoardRepositoryTests.java 에서 테스트를 진행
@Autowired
private BoardRepository boardRepository;
@Autowired
private BoardService boardService;
@Test
void testThreeHunderedBoards() {
for (int i = 0; i < 300; i++) {
this.boardService.setBoard(String.format("테스트 데이터 - [%03d]", i+1),
"별 내용 없습니다.");
}
}
- 300개의 더미 데이터를 넣기 위한 메소드
결과 화면
- 더미데이터가 잘 들어간 것을 확인할 수 있다!
'Spring Boot > STUDY' 카테고리의 다른 글
[Spring Boot] JPA 프로젝트 - Spring Security (0) | 2024.06.20 |
---|---|
[Spring Boot] JPA 프로젝트 - 페이징 기능 구현 (0) | 2024.06.20 |
[Spring Boot] BuildResult란? (0) | 2024.06.19 |
[Spring Boot] @Valid을 통한 게시글 등록 유효성 검사 (1) | 2024.06.19 |
[Spring Boot] JPA 프로젝트 - Thymeleaf로 레이아웃 템플릿 생성 (0) | 2024.06.19 |