두 손끝의 창조자

junit5 병렬 테스트 실행 본문

프로그래밍

junit5 병렬 테스트 실행

codinglog 2021. 5. 26. 14:46

resources/junit-platform.properties 파일 만들고

junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.config.strategy=dynamic
junit.jupiter.execution.parallel.mode.default = same_thread
junit.jupiter.execution.parallel.mode.classes.default = same_thread

밑에 config는 스레드 개수를 설정한다. 자신의 상황에 맞춰서 아래 링크를 참조하여 수정

https://junit.org/junit5/docs/snapshot/user-guide/index.html#writing-tests-parallel-execution

 

JUnit 5 User Guide

Although the JUnit Jupiter programming model and extension model will 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 cus

junit.org

dynamic은 사용 가능한 프로세서 / 코어 수에 junit.jupiter.execution.parallel.config.dynamic.factor 구성 매개 변수 (기본값 1)를 곱하여 원하는 병렬 처리를 계산 한다.

그리고 수행하고자 하는 테스트 클래스 위에 @Execution(ExecutionMode.CONCURRENT)

라고 붙이면 해당 클래스의 테스트는 병렬로 수행된다. 반대로 같은 스레드에서 동작하게 ExecutionMode 만 바꿔주면 된다.

 

 

반응형
Comments