▲ BoardServiceTests.java - JUnit 테스트 > SPRING1

본문 바로가기

사이트 내 전체검색

뒤로가기 SPRING1

▲ BoardServiceTests.java - JUnit 테스트

페이지 정보

작성자 관리자 작성일 24-07-30 11:00 조회 1,095 댓글 0

본문

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);

}


}


댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기