티스토리 뷰

개요

  • 2025년 9월 30일 JUnit 6(세부버전 6.0.0)이 발표되었다.
  • 발표되었는지도 몰랐는데 JUnit을 5에서 6으로 버전업해달라는 의뢰가 들어옴.

 

상황

시스템

  • Spring boot 3.5.3을 사용중
  • Spring boot 3.5.3의 JUnit은 Ver.5.12.2이다.

 

대응 방법

A. JUnit만 버전업

  • 변경되는 라이브러리인 JUnit에 대해서만 검증하면 됨

B. Spring boot를 4로 버전업

  • 전체적으로 버전업이 되어 취약성 해소와 성능 개선이 기대됨
  • 변경된 라이브러리에 대한 검증이 필요

 

실제 대응

큰 문제가 없다면 더 나을 것 같아서 Spring boot의 버전업을 먼저 실행해 봄.

버전 확인

  • 4의 세부버전은 4.0.0이 최종버전인데 아직 정식버전은 아닌 듯 함.

  • 4.0.0은 초기 버전이라 LTS가 아닌 듯 함. 어차피 다시 버전업할 필요가 있음.

Spring boot를 버전업 시도함.

4.0.0-RC1으로 버전업하니 다음의 클래스를 찾지 못하는 에러가 발생.

 

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
  • jsr310은 그룹ID가 com.fasterxml.jackson.datatype에서 tools.jackson.datatype으로 변한 듯 하고
  • Jackson2JsonDecoder, Jackson2JsonEncoder는 Spring framework 7부터 Deprecated되었음

게다가 사용중인 spring-boot-starter-jersey은 4.0.0-M2에서 멈춰있는 상태.

 

 

JUnit만 버전업하기로 하였다.

기존 라이브러리 버전.(인텔리제이의 부분화면)

  • junit-jupiter는 5.12.2, junit-platform은 1.12.2이다.

 

pom.xml에서 JUnit의 버전을 지정

  • 다음에 또 바꾸기 쉽게 property로 지정
  • 전체를 쉽게 바꾸는 방법은 찾지 못해서 각 artifact별로 다 지정해 주었다.
    • dependencyManagement에서 각 버전을 지정해주었다.

바뀐 라이브러리 버전.(Ver.6.0.1)

 

 

결론

  • junit-jupiter와 junit-platform의 버전이 같아짐
    • junit-jupiter Ver.5.12.2의 경우 junit-platform은 Ver.1.12.2
    • junit-jupiter Ver.6.0.1의 경우 junit-platform도 Ver.6.0.1
  • JUnit6의 새로운 기능을 사용하지 않고 기존 테스트 코드에 버전업만 한거라 특별히 바뀐 것은 없음.
  • JUnit4의 경우 마이그레이션 안내 페이지도 있지만 JUnit5 -> JUnit6은 큰 변화가 없는 듯.

 

참고자료

https://docs.junit.org/current/user-guide/

 

JUnit User Guide

Although the JUnit Jupiter programming model and extension model do not support JUnit 4 features such as Rules and Runners natively, it is not expected that source code maintainers will need to update all of their existing tests, test extensions, and custo

docs.junit.org

https://spring.io/projects/spring-boot#support

 

Spring Boot

 

spring.io