Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- JQuery
- fullcalendar
- LIST
- 스프링데이터흐름
- calendar
- jQuery값전송
- javascriptcalendar
- values()
- joinfetch
- jscalendar
- jQueryUI
- namedQuery
- 페이징
- JPQL
- Hibernate
- fetchjoin
- 제네릭
- 페치조인
- paging
- 벌크연산
- 제너릭
- springflow
- 프로젝트생성
- 엔티티직접사용
- jQuery값전달
- 대량쿼리
- JPA
- Generic
- 자바서블릿
- javaservlet
Archives
- Today
- Total
가자공부하러!
Spring Boot 테스트 활용(1) - JUnit 기초 환경설정 본문
개발환경
Spring Boot 2.2.2
JDK 1.8
1. 디펜던시
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
2. 컨트롤러
@RestController
@RequestMapping(value = "/member")
public class MemberRESTController {
@RequestMapping(value = "/chkConnection", method = RequestMethod.POST)
public String chkConnection() {
log.info("connection check");
return "ok";
}
}
3. 테스트
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@AutoConfigureMockMvc
public class MemberCommonTest {
@Autowired
MockMvc mockMvc;
@Test
public void controllerConnectionTest() throws Exception {
mockMvc
.perform(post("/member/chkConnection")
.param("name","min"))
.andDo(print());
}
}
'공부 > Java' 카테고리의 다른 글
모던자바인액션(CH1) - 자바8부터 추가된 것들 (0) | 2020.03.29 |
---|---|
Hibernate(13) - 연관관계 매핑 연습 (0) | 2019.12.24 |
JUnit test 메소드 실행 순서 설정 (0) | 2019.12.23 |
QueryDSL 간단 예제(1) - select, update (2) | 2019.12.18 |
Proxy (0) | 2019.11.29 |
Comments