통합테스트 (Integration Test)
두개 이상의 모듈이나 클래스를 테스트 할 수 있다
모듈 간의 연결에서 발생하는 에러 검증 가능
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) // 서버의 PORT 를 랜덤으로 설정합니다.
@TestInstance(TestInstance.Lifecycle.PER_CLASS) // 테스트 인스턴스의 생성 단위를 클래스로 변경합니다.
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest에너테이션으로 스프링 실행되게 함(unit test시에는 스프링 실행 안됨)
class ProductServiceIntegrationTest {
    @Autowired
    ProductService productService;
    @Autowired
    UserRepository userRepository;
@Autowired사용해 다른 클래스 가져오기
@Test
@Order(1)
@DisplayName("신규 관심상품 등록")
void test1() {
    // given
    // when
    // then
}
@Order로 순서 지정
'Spring' 카테고리의 다른 글
| [TIL] 231206Spring @RequestParam (0) | 2023.12.06 | 
|---|---|
| [TIL] 231206Spring Optional, 쿠키, 세션 만들기, JWT (0) | 2023.12.06 | 
| [TIL] 231130Spring 단위테스트 Unit Tests 반복테스트 Assertions Given-When-Then (0) | 2023.11.30 | 
| [TIL] 231130Spring Timestamped @Service @Transactional (0) | 2023.11.30 | 
| [TIL] 231124 Spring Security 로그인 (1) | 2023.11.24 |