SpringBootTest

삽질..

[JUnit5] @BeforeAll, @AfterAll Non-static method로 구현하기

문제 상황 : Test Method끼리 공유하는 Bean 필요 JUnit5를 이용해 Spring Boot 프로젝트의 테스트코드를 작성하는 도중이었다. 하나의 @SpringBootTest 클래스 안에 존재하는 여러 개의 @Test method가 공유하는 Repository를 생성하고 싶었다. 코드로 말하면 아래와 같은 상황이다. @BeforeAll이 붙은 method가 테스트 method들을 실행하기 전 10명의 유저를 userRepository에 저장한다. 그 후 2개의 test method가 userRepository에 저장된 것을 테스트하는 것이다. @SpringBootTest public class EntityTest { @Autowired private UserRepository userRepos..

김부추
'SpringBootTest' 태그의 글 목록