▲ BoardServiceTests.java - JUnit 테스트
페이지 정보
![profile_image](https://dancepkt.cafe24.com/data/member_image/ad/admin.gif?1630310007)
본문
package com.pkt.controller;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.pkt.model.BoardVO;
import com.pkt.service.BoardService;
import lombok.Setter;
import lombok.extern.log4j.Log4j;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/root-context.xml" })
@Log4j
public class BoardServiceTests {
@Setter(onMethod_ = @Autowired)
private BoardService service;
//@Test //목록
public void testGetList() {
service.listAll().forEach(board -> log.info(board));
}
//@Test //글쓰기
public void testCreate() {
BoardVO board = new BoardVO();
board.setTitle("서비스 글 제목");
board.setContent("서비스 내용이다.");
board.setWriter("1111");
service.regist(board);
}
//@Test //읽기
public void testRead() {
log.info(service.readOne(2));
}
//@Test //수정
public void testUpdate() {
BoardVO board = new BoardVO();
board.setBno(2);
board.setTitle("수정된 글이다.");
board.setContent("수정된 내용이다.");
service.modify(board);
}
//@Test //삭제
public void testDelete() throws Exception{
service.remove(2);
}
}
- 이전글BoardServiceImpl.java 24.07.30
- 다음글● ③ 영속 영역의 CRUD 구현 24.07.30
댓글목록
등록된 댓글이 없습니다.