개발정보/자바 스프링

스프링 부트 코딩 공작소 4장 단위테스트

dev김 2019. 1. 21. 13:17

@ContextConfiguration 대신 @SpringApplicationConfiguration을 사용

@RunWith(SpringJUnit4ClassRunner.class)

mockMvc

웹 통합 테스트

MockMvcBuilders standAloneSetup() 수동 하나 webAppContextSetup() 자동 통합


웹 보안 테스트

testCompile('org.springframework.security:spring-security-test') springSecurity()


@WithMockUser 새로유저 생성 @WithUserDetails 기존 유저 조회


@WebIntegrationTest 실행중 애플리케이션 테스트

@WebIntegrationTest(value={"server.port=0"}) ("server.port=0") 

@WebIntegrationTest(randomPort=true) local.server.port에 설정됨


셀레늄으로 html페이지 테스트

testCompile("org.seleniumhq.selenium:selenium-java:2.53.0")

스프링 부트 1.3.6버전에서 동작하기 위해선 46.0.1버전의 파이어폭스가 필요했다

추후에 테스트하게 된다면 해당 버전에 맞게 확인하고 설정하자