반응형

Test/Junit 5

[MockMvc] Pageable

@BeforeEach public void before(){ this.mockMvc= MockMvcBuilders.standaloneSetup(new PostRestController(this.postService)) .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver()) .build(); } class PageableHandlerMethodArgumentResolver 웹 요청에서 페이징 정보를 추출하므로 Pageable 인스턴스를 컨트롤러 메소드에 주입한다. class StandaloneMockMvcBuilder @Controller 등록을 허용하는 MockMvcBuilder는 일반 단위 테스트와 유사한 컨트롤러의 인스턴스화 ..

Test/Junit 2022.09.17

[Error] Internal Error occurred. org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests

Junit5는 JUnit Platform, JUnit Jupiter, JUnit Vintage 모듈이 있어야한다. testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0' testImplementation 'org.junit.platform:junit-platform-launcher:1.9.0' testImplementation 'org.junit.vintage:junit-vintage-engine:5.9.0' 참고 👇 https://junit.org/junit5/docs/current/user-guide/ JUnit 5 User Guide Although the JUnit Jupiter programming model and extension model ..

Test/Junit 2022.09.12

JUnit5

h2 데이터베이스로 테스트할 때 application.properties에서 아래와 같이 변경(수정해야 하는 부분만 가져옴) Mockito를 사용하면 DB 안 거치니까 필요없다. spring.datasource.url=jdbc:h2:tcp://localhost/~/test spring.datasource.driver-class-name=org.h2.Driver JUnit 5는 Architecture Jupiter, Vintage, JUnit Platform로 나뉘어 진다. Jupiter와 Vintage 모두 JUnit Platform을 구현하는 구현체 Jupiter는 JUnit 5의 구현체 @Autowired를 선언하면 Jupiter가 Spring Container에게 빈 주입을 요청 어노테이션 @Bef..

Test/Junit 2022.01.27
반응형